Thursday, June 10, 2010

Setting up SSH Agent and solving agent issues when prompting for rsa password

Setting up SSH-Agent
1. Generate your key
ssh-keygen -t rsa
2. Copy the public key to the authorized_keys file
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
3. Copy the public key to the remote hosts
scp ~/.ssh/id_rsa.pub seasnake.techops.uk.betfair:~/.ssh/authorized_keys

If you are prompted for your id_rsa passkey do the following;
If using a windowing environment you may have set ssh-agent running in one window, therefore your SSH_AUTH_SOCK variable needs to be set in the other windows;
1. In the window that allows you to ssh without specifying a password of any kind type;
echo $SSH_AUTH_SOCK
2. Using the value returned, in the other terminal windows type;
SSH_AUTH_SOCK=

If you can't connect without a password on any terminals do the following;
1. Find the current ssh agent
ps -ef | grep ssh
2. kill the ssh-agent process
kill
3. Start a new ssh-agent process and set the shell variables
eval `ssh-agent`
4. Check that your SSH_AUTH_SOCK is set
echo $SSH_AUTH_SOCK
5. Now add your key to the agent
ssh-add
6. Enter your id_rsa password when prompted
7. Log on to your remote system without the password.

No comments:

Post a Comment