0

Using two CentOS 7 servers, I set up passwordless authentication with root users. It works fine. I tried to use the same method (with .pub and authorized_key files) with other local users. But these methods didn't work. SSH connections between the servers with these users still prompted for a password.

I started with this: ssh-keygen -t rsa

One of my servers is Jenkins. I want to do builds (file transfers at the least) with other CentOS 7 servers. I think I need passwordless authentication for the jenkins user. I tried appending the contents of the .pub files in /root/.ssh/authorized_keys. I tried appending the contents of the .pub files in /home/jdoe/.ssh/authorized_keys. Instead of authorized_keys I also tried authorized_keys2. I expect passwordless authentication to work the same way with root as other users (as long as I don't enter a password when I generate the SSH key). But this isn't what I am experiencing. The root users can authenticate with no password over SSH. Non-root users aren't doing that. What should I do?

2
  • you should use "-v" for ssh session and observe debug information. My guess : check if file permissions for jdoe user' ssh keys. This user has to be the owner of whole .ssh dir, file permissions has to be set to 600.
    – MAQ
    Jan 30, 2016 at 11:11
  • The SSH server logs provide the most useful information for debugging SSH connections. Jan 30, 2016 at 13:09

1 Answer 1

1

You're more than likely running into a snag on the permissions. I usually leave authorized_keys to be 400 (though 640 will suffice). ~/.ssh should be 700. id_rsa I keep 400 as well. The less permissions the files have, the more ssh will be fine with them.

If you use the -v switch on ssh, it will tell you this issue. /var/log/secure will also tell you what's going on.

As a rule of thumb, ssh-copy-id will take care of all of this for you. If you run it and then the keys start working, look at the permissions of the files after the fact.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .