The following steps can be used to ssh from one system to another without specifying a password.
Notes:
* The system from which the ssh session is started via the ssh command is the client.
* The system that the ssh session connects to is the server.
* These steps seem to work on systems running OpenSSH.
* The steps assume that a RSA key is being used. To use a DSA (insecure) key substitute 'rsa' with 'dsa'.
* The steps assume that you are using a Bourne-like shell (sh, ksh or bash)
Steps:
1. On the client run the following commands:
$ mkdir -p $HOME/.ssh
$ chmod 0700 $HOME/.ssh
$ ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -P "your_private_pass_key"
SKIP the -P private_pass_key if you don't wanna be prompted for password
This should result in two files, $HOME/.ssh/id_rsa (private key) and $HOME/.ssh/id_rsa.pub (public key).
NOTE: steps [2,3,4 and 5] can be skipped using:
ssh-copy-id -i .ssh/id_rsa.pub user@domain.com
2. Copy $HOME/.ssh/id_rsa.pub to the server.
3. On the server run the following commands:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
$ chmod 0600 $HOME/.ssh/authorized_keys2
Depending on the version of OpenSSH the following commands may also be required:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
$ chmod 0600 $HOME/.ssh/authorized_keys
An alternative is to create a link from authorized_keys2 to authorized_keys:
$ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys
4. On the client test the results by ssh'ing to the server:
$ ssh -i $HOME/.ssh/id_rsa server
5. (Optional) Add the following $HOME/.ssh/config on the client:
Host server
IdentityFile ~/.ssh/id_rsa
This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.
Helpful manpages:
* ssh(1)
* ssh-keygen(1)
* ssh_config(5)
SSH Without a Password
Who is online
Users browsing this forum: No registered users and 1 guest