Adding a public key to ~/.ssh/authorized_keys does not log me in automatically

前端 未结 30 2499
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 03:15

I added the public SSH key to the authorized_keys file. ssh localhost should log me in without asking for the password.

I did that and tried t

相关标签:
30条回答
  • 2020-12-02 04:02

    I issued sudo chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys and chmod go-w $HOME $HOME/.ssh from a previous answer and it fixed my problem on a CentOS 7 box that I had messed up the permissions on while trying to get Samba shares working.

    0 讨论(0)
  • 2020-12-02 04:03

    The thing that did the trick for me finally was to make sure that the owner/group were not root, but user:

    chown -R ~/.ssh/ user
    chgrp -R ~/.ssh/ user
    
    0 讨论(0)
  • 2020-12-02 04:05

    Beware that SELinux can trigger this error as well, even if all permissions seem to be OK. Disabling it did the trick for me (insert usual disclaimers about disabling it).

    0 讨论(0)
  • 2020-12-02 04:07

    It seems like a permission problem. Usually it happens if the permission of some file/directory is not correctly set up. In most case they are ~/.ssh and ~/.ssh/*. In my case they are /home/xxx.

    You can change the log level of sshd by modifying file /etc/ssh/sshd_config(search for LogLevel, and set it to DEBUG) and then check the output in file /var/log/auth.log to see what happened exactly.

    0 讨论(0)
  • 2020-12-02 04:08

    Another tip to remember: Since v7.0 OpenSSH disables DSS/DSA SSH keys by default due to their inherit weakness. So if you have OpenSSH v7.0+, make sure your key is not ssh-dss.

    If you are stuck with DSA keys, you can re-enable support locally by updating your sshd_config and ~/.ssh/config files with lines like so: PubkeyAcceptedKeyTypes=+ssh-dss

    0 讨论(0)
  • 2020-12-02 04:08

    This solves my problem:

    ssh-agent bash
    
    ssh-add
    
    0 讨论(0)
提交回复
热议问题