Windows-to-*nix public key authentication
I've worked with lots of servers, most of which I cannot access directly, so I often use remote access: Remote Desktop Connection or Terminal Services in Windows, and
While I do have PasswordSafe to remember all those passwords, I'm the lazy admin type, so I often opt for password-less authentication using public keys. For this, I use PuTTY, et. al.
Seems tedious at first, but I can then export
ssh in *nix.While I do have PasswordSafe to remember all those passwords, I'm the lazy admin type, so I often opt for password-less authentication using public keys. For this, I use PuTTY, et. al.
- First, I generate an RSA key using PuTTYgen. I don't enter anything for the passphrase. Warning: NOT recommended for production servers!
- I save the public and secret keys (in .PPK format) in a directory. I also cut and paste the RSA string in a text file,
key.txt. - For now, the remote box is configured for "normal" ssh, that is, through password authentication. So, I copy over the RSA string file to the remote box:
C:\> pscp \path\to\key.txt user@remote-host:/home/user/.
- I log on to the remote host using PuTTY, and do the following:
$ mkdir .ssh
$ mv key.txt .ssh/authorized_keys
$ chmod 700 .ssh; chmod 600 .ssh/authorized_keys - I also edit the SSHd config file,
/etc/ssh/sshd_config, with the following parameters:RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
PermitRootLogin no - SSHd is then restarted.
- Back in Windows, I launch PuTTY, and enter the host name for the remote box. In the SSH/Auth category, I place the private key file saved earlier. I save the session, named
remote-nopass. - I then launch Pageant, drill down to Saved Sessions > remote-nopass. It will bring up the SSH login page, where I enter my login name, after which, I am authorized through the pubkey, and log in to the SSH session.
Seems tedious at first, but I can then export
key.txt to other remote servers, and just save sessions for Pageant's use. Pageant is conveniently located in the system tray within reach.
Comments
Post a Comment