Centos – Passwordless SSH (Windows –> CentOS)

centosssh

I am trying to get passwordless SSH authentication to work from a Windows 7 machine to local server.

  1. Windows machine: My login name in this machine is MY_LOGIN_NAME. I am using Cygwin as the command line.

  2. CentOS 5.5 Server: I have admin privileges on this server; logged in as root.

Here is what I have done so far:

  1. Logged into MY_LOGIN_NAME on the Windows machine, I ssh-config-usered from the Cygwin command line. This created (at least) RSA public and private keys in C:/Users/MY_LOGIN_NAME/.ssh

  2. I copied the public key over to the server to the .ssh directory using scp.

    scp id-rsa.pub root@xxx.xxx.xx.xx:.ssh/id-rsa.pub

  3. Then I tried to log into the server using ssh like so:

    ssh -i id_rsa root@xxx.xxx.xx.xx

But it still asks me for my password. What am I missing?

Best Answer

The problem is your step 2. You overwrote root@xxx.xxx.xx.xx public key with your Cygwin public key. That's not what you want.

You should, instead, add your public key to root@xxx.xxx.xx.xx authorized keys. This can be done manually appending your id-rsa.pub to /root/.ssh/autorized_keys (on CentOS), or automagically running ssh-copy-id on Cygwin.

ssh-copy-id root@xxx.xxx.xx.xx

It will prompt for your password and then you should be fine.

Also, you should recover root@xxx.xxx.xx.xx public key, or generate a new pair, if it's not inconvenient.

Related Question