Tuesday, March 18, 2008

ssh login without re-entering password

At my work, i have to enter our hosting server. Sometimes, several times a day. And obviously I have to enter password to get through.

I knew the solution before. We used to do this in our distributed systems lab at college. Because, sometimes it becomes necessary to enter a remote machine without password by the automated scripts.

And today I had to rediscover this again ;)

Enter the remote machine and check there exists .ssh folder under `~` (home) folder. if it doesn't exist, create one.
mkdir ~/.ssh

then 'exit' to come back to your own console.
2. create your own key. For simplicity, just press enter at all prompts
ssh-keygen -t dsa

3. Copy your ssh key to remote host
cat ~/.ssh/id_dsa.pub | ssh <remote_host_address> "cat - >> ~/.ssh/authorized_keys"

VoilĂ ! You're done. Now try to ssh again to the remote host. You'll get the remote shell without any password :)

No comments: