Log on to the Linux server using SSH without a password
In the following example, ssky-keygen and ssh-copy-id can be used to log on to a remote Linux host without a password.
Ssh-keygen creates the public key and key.
Ssh-copy-id copies the public key of the local host to the authorized_keys file of the remote host.
The ssh-copy-id will also be sent to the user home directory (home) and ~ of the remote host ~ /. Ssh, and ~ /. Ssh/authorized_keys.
Step 1: Use ssh-key-gen to create a public key and a key on the local host
Bkjia @ local-host $ ssh-keygen-t rsa
Enter file in which to save the key (/home/jsmith/. ssh/id_rsa): [Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in/home/jsmith/. ssh/id_rsa.
Your public key has been saved in/home/jsmith/. ssh/id_rsa.pub.
The key fingerprint is: 33: b3: fe: af: 95: 95: 18: 11: 31: d5: de: 96: 2f: f2: 35: f9
Bkjia @ local-host
Step 2: Use ssh-copy-id to copy the public key to the remote host.
Bkjia @ local-host $ ssh-copy-id-I ~ /. Ssh/id_rsa.pub [email protected]
Bkjia @ remote-host's password:
Now try logging into the machine, with-ssh? Remote-host '', and check in:
. Ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
[Note: The ssh-copy-id appends the key to. ssh/authorized_key of the remote host.]
Bkjia @ local-host $ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
Bkjia @ remote-host $
[Note: You have logged on to the remote host]
How to Improve the SSH login authentication speed of Ubuntu
Enable the SSH service to allow Android phones to remotely access Ubuntu 14.04
How to add dual authentication for SSH in Linux
Configure the SFTP environment for non-SSH users in Linux
Configure and manage the SSH service on Linux
Basic SSH tutorial
SSH password-free logon details
This article permanently updates the link address: