I've encountered an error when trying to setup so I can connect to my HTPC with my laptop, I've followed this guide from ubuntu help

This is my ~/.ssh/ permissions on my remote host

-rw------- 1 htpc htpc  398 Feb 29 15:16 authorized_keys
-rw------- 1 htpc htpc 1675 Feb 29 15:15 id_rsa
-rw-r--r-- 1 htpc htpc  391 Feb 29 15:15 id_rsa.pub

this is my /etc/ssh/sshd_config file on remote host

# Authentication: 
LoginGraceTime 120 
PermitRootLogin without-password 
StrictModes yes
RSAAuthentication yes 
PubkeyAuthentication yes 
AuthorizedKeysFile      %h/.ssh/authorized_keys

When I try to enter from my local machine through SSH, it still ask me for a password even though my public ssh key is inside the authorized_keys on the remote host.

Debug log when connecting from local machine to htpc

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/mikeyr/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/mikeyr/.ssh/id_dsa
debug1: Trying private key: /home/mikeyr/.ssh/id_ecdsa
debug1: Trying private key: /home/mikeyr/.ssh/id_ed25519
debug1: Next authentication method: password

I've tried with my router as well and I have no issues getting it to work on that.

  • What are the permissions of ~/.ssh directory? If they're not rwx------ (700) or r-x------ (500) and directory owner+group=user's (htpc here), then the authorized_keys file is also ignored. Next up: check that your local key from /home/mikeyr/.ssh/id_rsa.pub is listed in remote .ssh/authorized_keys – Piskvor Feb 29 '16 at 15:16
  • My /home/mikeyr/.ssh/id_rsa.pub is listed in /home/htpc/.ssh/authorized_keys Also I've just set the permission to chmod 700 on .ssh folder without any success of connecting without entering pw drwx------ 2 htpc htpc 4096 Feb 29 15:21 .ssh – MikeyR Feb 29 '16 at 15:23
  • Check also this list at U&L site: unix.stackexchange.com/questions/16978/… – Piskvor Feb 29 '16 at 15:30
  • 1
    Holy damn, that solution worked, I've tried to do chmod 755 on all three directories ~, .ssh and .ssh/authorized_keys then restarted the service and now it works, thanks! – MikeyR Feb 29 '16 at 15:38
  • One last thing, since I don't know the protocol of askubuntu, should I let you post an answer providing the link so I can accept the answer? Or should I edit my post, telling that link fixed it or post the answer myself? – MikeyR Feb 29 '16 at 15:41

Note that your /etc/ssh/sshd_config contains the line

 StrictModes yes

Specifies whether sshd should check file modes and ownership of the user's files and home directory before accepting login. This is normally desirable because novices sometimes accidentally leave their directory or files world-writable. The default is ''yes''.

In other words, your home directory ~ on the remote host should be owned and group-owned by you (in this case, this probably means owner htpc and group htpc), and only writable by you (and potentially your group): that means no write in the last ("world") column

$ ls -la ~/
drwxr-xr-x 41 htpc htpc .

Note that the last part says r-x (not world writable), NOT rwx.

If there's a rwx in the last triplet, you need to remove the write rights:

chmod a-w ~

Similarly for the ~/.ssh folder and ~/.ssh/authorized_keys. I would recommend chmod 700 ~/.ssh to only grant access to yourself for the folder, and chmod 600 ~/.ssh/authorized_keys for the file.

(Also see https://unix.stackexchange.com/a/16981/5477 for more server-side debugging tools)


Maybe while generating ssh-key you have added password to a key.

Generate new ssh-key ssh-keygen

Enter passphrase (empty for no passphrase): <- press enter as for default ( no password ).

Then ssh-copy-id user@host

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.