Monday, February 4, 2008

Auto ssh login from Cygwin to linux server

I have a ssh2 client software installed before the installation of cygwin, but I never tried the auto login by public key successfully, one reason, I guess, is that my remote server doesn't have SSH2 server installed. Now that I am using cygwin, i install the openssh (not openssl) module from cygwin installation packages.

[cygwin:~/] ssh-keygen -t rsa (leave passphrase empty to make ssh-login easier)
[cygwin:~/] cd .ssh
[cygwin:~/] scp id_rsa.pub username@remote_host:.ssh/ (enter password this time)
[cygwin:~/] ssh username@remote_host (enter password this time)
[remote_host:~/] cd .ssh (create one if not existed)
[remote_host:~/] touch authorized_keys (create this file is not existed)
[remote_host:~/] cat id_rsa.pub >> authorized_keys
[remote_host:~/] rm -f id_rsa.pub
[remote_host:~/] chmod 600 authorized_keys
[remote_host:~/] cd ..
[remote_host:~/] chmod 700 .ssh
[remote_host:~/] exit
[cygwin:~/] ssh username@remote_host
[========== no password anymore, also for scp ===========]

2 comments:

Gustavo Gonnet said...

excellent, thanks!

LK Gandhi said...

_/\_ awesome! thanks!!!
worked in my university