Skip to content

Instantly share code, notes, and snippets.

@zero-entropy-universe
Last active December 8, 2017 00:09
Show Gist options
  • Select an option

  • Save zero-entropy-universe/b6a51129d16c181af3235f87acc3f604 to your computer and use it in GitHub Desktop.

Select an option

Save zero-entropy-universe/b6a51129d16c181af3235f87acc3f604 to your computer and use it in GitHub Desktop.

SSH Login Without Password

1. Log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:(normally, A is your computer)

a@A:~> ssh-keygen -t rsa

Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

2. Check ~/.ssh directory

if ~/.ssh directory already exists, go to step 4

ls -la ~/.ssh

3. Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):

a@A:~> ssh b@B mkdir -p .ssh

b@B's password:

4. Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'

b@B's password:

πŸ‘ πŸ‘ πŸ‘ From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment