This question already has an answer here:

My permissions look like this:

-rw-------.  1 smpadmin staff     400 May 21  2014 id_rsa.pub
-rw-r--r--.  1 smpadmin staff     505 Dec 14 19:19 known_hosts
drwxr-xr-x. 45 smpadmin staff    4096 Jan 20 09:53 ..
-rw-r--r--.  1 smpadmin staff     386 Jan 20 10:32 config
-rwx------.  1 smpadmin staff     400 Jan 20 10:34 authorized_keys
-rwx------.  1 smpadmin staff      400 Jan 20 10:37 authorized_keys2
drwx------.  2 smpadmin staff    4096 Jan 20 10:37 .

The log:

debug3: record_hostkey: found key type RSA in file /home/alejanpi/.ssh/known_hosts:85
debug3: load_hostkeys: loaded 1 keys from x.x.150.86
debug1: Host 'x.x.150.86' is known and matches the RSA host key.
debug1: Found key in /home/alejanpi/.ssh/known_hosts:85
debug2: bits set: 1525/3072
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/alejanpi/.ssh/id_rsa (0x60005ff50),
debug2: key: /home/alejanpi/.ssh/id_dsa (0x0),
debug2: key: /home/alejanpi/.ssh/id_ecdsa (0x0),
debug2: key: /home/alejanpi/.ssh/id_ed25519 (0x0),
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/alejanpi/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/alejanpi/.ssh/id_dsa
debug3: no such identity: /home/alejanpi/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/alejanpi/.ssh/id_ecdsa
debug3: no such identity: /home/alejanpi/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/alejanpi/.ssh/id_ed25519
debug3: no such identity: /home/alejanpi/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
smpadmin@x.x.150.86's password:

I added the public key to both authorized key files.

By comparing to another server where I have the same keys working, the logs on this one show at some point:

Server accepts key: pkalg ssh-rsa blen 277

I also noticed a different hex code in this part of the logs:

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/alejanpi/.ssh/id_rsa (0x60006c5f0),

Now, for the server where my keys are not working, /home used to be on /, but I mounted it to a different disk. My keys used to work before I moved /home. Not sure if this is affecting me, but I thought it'd be worth mentioning. This is how I mounted home:

UUID=143f3a8a-55f3-41e4-8797-d1cdb0435c13 /home                   ext4    defaults        0 2

SELinux permissions.

drwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 .
drwxr-xr-x. smpadmin staff unconfined_u:object_r:user_home_dir_t:s0 ..
-rwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 authorized_keys
-rwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 authorized_keys2
-rw-r--r--. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 config
-rw-------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 environment
-rw-------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 id_rsa.pub
-rw-r--r--. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 known_hosts

The home directory has: drwxr-xr-x. root root system_u:object_r:file_t:s0 home

I hope you guys can help me.

Ty.

marked as duplicate by Gilles ssh Jan 20 '16 at 22:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    What is in your /var/log/secure file? Post the most recent entries from the failure. – devnull Jan 20 '16 at 18:05
  • i suppose there is something wrong with the permissions on the server side. did you re-start the sshd on the server since re-mount? also please give us the content of "/etc/mtab", and the output of "ls -la /home" – gerhard d. Jan 20 '16 at 18:47
  • Is the ls -l ~/.ssh at the top of your question the directory on the server? Please provide the same listing for the client as it could be permissions issue. Or perhaps you're missing the private key on the client. Also, is the debug listing from the server or the client? Please could you edit your question to make it clear which parts are from the client and which are from the server. Thanks. – roaima Jan 20 '16 at 18:56
  • 1
    SELinux is involved, so: restorecon -R -v ~/.ssh – Gilles Jan 20 '16 at 22:48
up vote 3 down vote accepted

Maybe you are not looking for the correct permission set.

Have you tried to temporarily disabled SELinux, if you can?

In the server you are trying to access console:

# setenforce 0

And try to access again.

If it works, is a SELinux related problem.

Then if you want to solve the problem get the correct permissions.

First take a look at the ACL of that file with:

# ls -alZ authorized_keys
-rw-r--r--. root root unconfined_u:object_r:ssh_home_t:s0 authorized_keys

If it doesn't show the unconfined_u:object_r:ssh_home_t:s0 then change the permissions with chcon

# chcon unconfined_u:object_r:ssh_home_t:s0 authorized_keys
  • Those permissions look good. -rwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 authorized_keys -rwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 authorized_keys2 – Alex Pi Jan 21 '16 at 0:38
  • Changing SELinux to permissive mode did the trick. But I don't understand why this doesn't work if my permissions are just like described above. I added my selinux permission to the original question. – Alex Pi Jan 21 '16 at 0:59
  • I found the permission that was wrong. It was the /home I mounted, it had system_u:object_r:file_t:s0 instead of system_u:object_r:home_root_t:s0 . Your answer put me in the right direction David, thank you!!! – Alex Pi Jan 21 '16 at 1:10

You are trying to authenticate to user smpadmin and you show us the permissions of ~user/.ssh (at least according to owner/group).

The directory ~/.ssh should be owned by the owner of the home directory, as all the other files inside. You copied it from different user and didn't change owner or you are connecting to wrong user.

  • Sorry that was an edition error, permissions are actual set to smpadmin. – Alex Pi Jan 21 '16 at 0:34

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