To save having to type my password each time from my laptop, I configured SSH to allow my laptop to login securely without typing the password. Here's how:
Step 1: Use ssh-keygen to create public and private keys on my MacBookPro
MacBookPro:~ neil$ [Note: I am on the local-host here] MacBookPro:~ neil$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/neil/.ssh/id_rsa):[ENTER] Enter passphrase (empty for no passphrase): [ENTER] Enter same passphrase again: [ENTER] Your identification has been saved in /Users/neil/.ssh/id_rsa. Your public key has been saved in /Users/neil/.ssh/id_rsa.pub. The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 neil@MacBookPro
Step 2: Copy the public key to remote host (Linux Mint)
MacBookPro:~ neil$ cat ~/.ssh/id_rsa.pub | ssh neil@LinuxMint "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
Step 3: Login without a password using SSH
MacBookPro:~ neil$ ssh LinuxMint Last login: Sun Nov 16 17:22:33 2008 from 192.168.10.2 [Note: SSH did not ask for password.] neil@LinuxMint$ [Note: You are on the remote-host here]At that is it!
There is another command called ssh-copy-id that will perform step 2 but this wasn't available on my MacBook Pro. You use that command like so:
neil@ubuntu$ ssh-copy-id -i ~/.ssh/id_rsa.pub LinuxMint neil@LinuxMint's password: Now try logging into the machine, with "ssh 'LinuxMint'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
0 Comments