Friday, January 15, 2010

ssh-agent : ssh agent forwading

aFirst create ssh-keys using

ssh-keygen -t dsa
ssh-keygen -t rsa

Assuming they are written to default location lets proceed.

Check if there are any existing keys

-bash-2.05b$ ssh-add -l
Could not open a connection to your authentication agent.

Start the ssh-agent

-bash-2.05b$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-HYsGOxmf/agent.78451; export SSH_AUTH_SOCK;
SSH_AGENT_PID=78452; export SSH_AGENT_PID;
echo Agent pid 78452;
-bash-2.05b$ SSH_AUTH_SOCK=/tmp/ssh-HYsGOxmf/agent.78451; export SSH_AUTH_SOCK;
-bash-2.05b$ SSH_AGENT_PID=78452; export SSH_AGENT_PID;

Add Your keys

-bash-2.05b$ ssh-add .ssh/id_dsa
Identity added: .ssh/id_dsa (.ssh/id_dsa)
-bash-2.05b$ ssh-add .ssh/id_rsa
Identity added: .ssh/id_rsa (.ssh/id_rsa)
-bash-2.05b$ ssh-add -l
1024 6a:70:08:2b:71:83:31:98:90:8f:99:f8:8d:96:55:0f .ssh/id_dsa (DSA)
2048 7a:01:2e:1f:88:ef:3:b6:48:3c:ee:d:dd:b4:6b:ff .ssh/id_rsa (RSA)
-bash-2.05b$ ssh -A $username@whicheverhost.com
Last login: Fri Oct 9 09:49:47 2009 from somehost.com

[root@somehost.com ~]# ssh username@whicheverhost-two.com
Last login: Fri Oct 9 09:46:18 2009 from x.com
[root@whicheverhost-two ~]#


you should also have your public keys pushed to .authorized_keys on both the hosts

No comments: