Creating SSH Keys
May 16, 08 by cjgibbsMy purpose for doing this was to automate file transfers between servers. So I needed a secure copy method (SCP) without prompting for a password (SSH keys). I’ll call my two systems production and backup. I need to be able to ssh from production to backup without it prompting for a password.
On production generate your private/public key pair:
chris@production ~$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/export/home/chris/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/chris/.ssh/id_dsa. Your public key has been saved in /export/home/chris/.ssh/id_dsa.pub. The key fingerprint is: bd:cf:bb:c0:30:1c:c3:5f:74:80:3b:f0:1f:82:20:bb chris@production
Put the public key file (id_dsa.pub) on the remote system you will be ssh’ing to as the authorized_keys2 file in the .ssh directory of the user you will be using to ssh:
chris@production ~$ scp ~/.ssh/id_dsa.pub backup:.ssh/authorized_keys2
Or append it if you have a preexisting authorized_keys2 file.
That’s it. You should be able to ssh from production to backup with whatever password you entered in the key generation process (or none if you didn’t enter one).