Simple Way (Better to try this)
1.Run the following command on the client (from where you want to access the
server)
#ssh-keygen -t rsa
2.id_rsa and id_rsa.pub files will be created inside $HOME/.ssh
3.Copy id_rsa.pub to the server’s .ssh directory
#mkdir $HOME/.ssh
#scp $HOME/.ssh/id_rsa.pub user@server:/home/user/.ssh
4.Change to /root/.ssh and create file authorized_keys containing id_rsa content
#cd /home/user/.ssh
#cat id_rsa >> authorized_keys
5.You can try ssh to the server from the client and no password will be needed
#ssh user@server
6.enable rsa authentication in /etc/ssh/sshd_config in both the servers
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
7.Restart sshd service ( service sshd restart)
A much more complex way
In the server where you want to give access
#ssh-keygen -t rsa
Give password
This will create two files Private key and public key in $HOME/.ssh/id_rsa.pub and $HOME/.ssh/id_rsa
#scp /root/.ssh/id_rsa.pub
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
.*.*:/home/test/.ssh/
# scp /root/.ssh/id_rsa
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
.*.*:/home/test/.ssh/
#exec ssh-agent bash
#ssh-add /root/.ssh/id_rsa
Remote Side
Create a user
#Useradd test
#Passwd test
#su – test
$mkdir /home/test/.ssh
$chmod 700 .ssh
$cat /home/test/.ssh/id_rsa >> /home/test/.ssh/ authorized_keys (if ssh2 then use authorized_keys2)
$ exec ssh-agent bash
$ssh-add /root/.ssh/id_rsa