Sunday, April 17, 2005

Set up public-key authentication between an OpenSSH client and an OpenSSH server

Generate a key if necessary:

$ mkdir -p ~/.ssh If it doesn't already exist
$ chmod 700 ~/.ssh
$ cd ~/.ssh
$ ssh-keygen -t dsa
Copy the public key to the remote host:

$ scp -p remoteuser@remotehost:
Password: ********
Log into the remote host and install the public key:

$ ssh -l remoteuser remotehost
Password: ********

remotehost$ mkdir -p ~/.ssh If it doesn't already exist
remotehost$ chmod 700 ~/.ssh
remotehost$ cat >> ~/.ssh/authorized_keys (Appending)
remotehost$ chmod 600 ~/.ssh/authorized_keys
remotehost$ mv ~/.ssh Optional, just to be organized
remotehost$ logout
Log back in via public-key authentication:

$ ssh -l remoteuser remotehost
Enter passphrase for key '/home/smith/.ssh/id_dsa': ********
Post a Comment