-
Notifications
You must be signed in to change notification settings - Fork 4
Passwordless SSH login
mrp-78 edited this page Jul 21, 2019
·
2 revisions
01. Check for existing SSH key pair
$ ls -al ~/.ssh/id_*.pub
If you see No such file or directory
or no matches found
it means that you do not have an SSH key and you can proceed with the next step and generate a new one.
02. Generate a new SSH key pair
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Press Enter
to accept the default file location and file name:
Output
Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):
Next, the ssh-keygen tool will ask you to type a secure passphrase.
If you don’t want to use passphrase just press Enter
Output
Enter passphrase (empty for no passphrase):
To be sure that the SSH keys are generated you can list your new private and public keys with:
$ ls ~/.ssh/id_*
Output
/home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub
03. Copy the public key
$ ssh-copy-id remote_username@server_ip_address -p server_port
You will be prompted to enter the remote_username password:
Output
remote_username@server_ip_address's password:
04. Login to your server using SSH keys
$ ssh remote_username@server_ip_address -p server_port
If everything went well, you will be logged in immediately.