I am trying to configure an ssh server, so that it accepts only keys (so disabling the request of the password).

I have already generated the public and private key using PuTTY (under Windows). I have two users currently, root and amministratore.  I don't want root to be able to login using ssh, only amministratore can.

What I've modified and done until now is:

  1. /etc/ssh/sshd_config – see https://pastebin.com/hp0EQ5hG

  2. root@autoapi:~# ls -ld ~/.ssh
    drwx------ 2 amministratore amministratore 4096 May  5 16:22 /home/amministratore/.ssh
  3. amministratore@autoapi:~/.ssh$ ls -l
    total 4
    -rw-r--r-- 1 amministratore amministratore 398 May  5 16:08 authorized_keys
  4. root@autoapi:~/.ssh# ls

    root@autoapi:~/.ssh# cat authorized_keys
    ssh-rsa AAAA.....KKQ== rsa-key-20190504

What have I forgotten?

  • Please show charges to /etc/ssh/sshd_config in question. And what is going wrong? May 5, 2019 at 17:30
  • 1
    There is something odd about output of ls -ld ~/.ssh when in ~root. May 5, 2019 at 17:34
  • Please show the error you are getting when attempting to connect to SSH. Running SSH with extra verbosity (-v, -vv, -vvv) would also be helpful to see what is going on. May 5, 2019 at 18:59
  • (1) In paragraph 2, you say you are running as root, looking in root’s home directory (/root?), but the output is for /home/amministratore. (2) What is your problem?  Is root ssh login succeeding?  Is amministratore not working? Please do not respond in comments; edit your question to make it clearer and more complete.
    – Scott
    May 5, 2019 at 19:05

2 Answers 2


When you connect with SSH, the client first checks to see what will be acceptable to the server. That is it asks the whether a particular key is acceptable before it actually trys to login. This means that if a particular key isn't acceptable the client won't even try to use it.

From your evidence the most likely thing is that your authorized_keys file is set to publicly readable and your config specifies the default # StrictModes yes. It also specifies # PasswordAuthentication yes. So the key authentication is being rejected by the server and instead you are being asked for a password. To fix this change two things.

1 Change the permissions on authorized_keys:

chmod go-rwx ~/.ssh/authorized_keys

2 Disable password authentication in /etc/ssh/sshd_config:

PasswordAuthentication no
  • Love you, it works!
    – user351481
    May 6, 2019 at 17:42

You have correctly set the config to not allow root login.

It looks like you need to set the permissions of the authorized_keys file of amministratore, to 600.

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.