1

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?

5

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.

  • Please note that even with the proper keys in place, unless the client side is running an ssh-agent with the appropriate key loaded, an ssh connection attempt will prompt for password/passphrase (of course, that is unless prohibited by some other configuration values). – Codex24 Mar 19 '18 at 19:27
1

Also, be aware of the PermitRootLogin option available in the server-side /etc/ssh/sshd_config file, which is described,

PermitRootLogin
Specifies whether root can log in using ssh(1). The argument must be "yes",
"without-password", "forced-commands-only", or "no". The default is "yes".

If this option is set to "without-password", password authentication is
disabled for root.  

Setting it to "without-password" has the effect of only allowing root to log in through ssh by having an authorized public key in place, which keeps Mallory from attempting to brute-force root's password. However, failure to authenticate via authorized public key manifests as repeated password prompts, which can be confusing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.