As a basis I used these two great website. First you need to configure the local machine or the machine that will need to make the connection. You first need to make a key
$ ssh-keygen -t dsa -b 2048 -f ~/.ssh/ssh-key Generating public/private dsa key pair. Enter passphrase (empty for no passphrase): [press enter here] Enter same passphrase again: [press enter here] Your identification has been saved in /home/user/.ssh/ssh-key. Your public key has been saved in /home/user/.ssh/ssh-key.pub. The key fingerprint is: 8c:57:af:68:cd:b2:7c:aa:6d:d6:ee:0a:5a:a4:29:03 user@localhost
Do not enter a passphrase as you otherwise need to enter it each time you connect. This is something you only need to do once.
Next you need to put the the public key ssh-key.pub on the remote machine. This can be done with e.g. scp, ftp, via email or any other means. scp is the easiest way.
scp ~/rsync-key.pub user@remotehost:~
You still need to place it in the correct file. If you do not have a directory ~/.ssh/ or a file ~/.ssh/authorized_keys you need to make them first. cmod the directory to 700 and the file to 600. Then you can add the content of the key to the file with
cat ssh-key.pub >> ~/.ssh/authorized_keys
You are now ready to connect and run commands remotely without the need of a password.
ssh -i ~/.ssh/ssh-key user@remotehost ssh -i ~/.ssh/ssh-key user@remotehost command -parameters
To make things even easier, I have the following in my alias file:
alias sshnl='ssh -i ~/.ssh/ssh-key remoteuser@example.com ' alias sshbe='ssh -i ~/.ssh/ssh-key remoteuser@example.net '
The first connects me to a server in the Netherlands, the second to one in Belgium. Now if you want to add more servers, just place the ssh-key.pub into the ~/.ssh/authorized_keys server of the remote machine. Each user will have its own unique key as can be seen at the end of the key, so adding more keys is no problem.
© 2005 by
houghi.
Copyright explanation will shortly follow on a page here.