Skip to content

Instantly share code, notes, and snippets.

@pcdinh
Created March 22, 2010 11:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcdinh/340004 to your computer and use it in GitHub Desktop.
Save pcdinh/340004 to your computer and use it in GitHub Desktop.
UserA at host1 -> UserB at host2: [UserA@host1 ~]ssh UserB@host2
=> no password required
1. In host1 as UserA
UserA@host1:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/UserA/.ssh/id_rsa):
Created directory '/home/UserA/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/UserA/.ssh/id_rsa.
Your public key has been saved in /home/UserA/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 UserA@host1
2. Create a directory ~/.ssh as UserB on host2. (The directory may already exist, which is fine):
UserA@host1:~> ssh UserB@host2 mkdir -p .ssh
UserB@host2's password:
3. Append UserA's new public key to UserB@host2:.ssh/authorized_keys and enter UserB's password one last time:
UserA@host1:~> cat .ssh/id_rsa.pub | ssh UserB@host2 'cat >> .ssh/authorized_keys & chmod 644 .ssh/authorized_keys & chmod 700 .ssh'
UserB@host2's password:
=> Test: [UserA@host1 ~] ssh UserB@host2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment