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

前端 未结 30 2498
爱一瞬间的悲伤
爱一瞬间的悲伤 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 03:50

    Try "ssh-add" which worked for me.

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

    In the following, user is your username.

    mkdir -p /home/user/.ssh
    ssh-keygen -t rsa
    touch /home/user/.ssh/authorized_keys
    touch /home/user/.ssh/known_hosts
    chown -R user:user /home/user/.ssh
    chmod 700 /home/user/.ssh
    chmod 600 /home/user/.ssh/id*
    chmod 644 /home/user/.ssh/id*.pub
    chmod 644 /home/user/.ssh/authorized_keys
    chmod 644 /home/user/.ssh/known_hosts
    
    0 讨论(0)
  • 2020-12-02 03:53

    In my case it's because the user's group is not set in AllowGroups of configuration file /etc/ssh/sshd_config. After adding it, everything works fine.

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

    I use it this way.

    cat ~/.ssh/id_rsa.pub| ssh user@remote-system 'umask 077; cat >>~/.ssh/authorized_keys'
    
    0 讨论(0)
  • 2020-12-02 03:57

    Listing a public key in .ssh/authorized_keys is necessary, but not sufficient for sshd (server) to accept it. If your private key is passphrase-protected, you'll need to give ssh (client) the passphrase every time. Or you can use ssh-agent, or a GNOME equivalent.

    Your updated trace is consistent with a passphrase-protected private key. See ssh-agent, or use ssh-keygen -p.

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

    Make sure you've copied the whole public key to authorized_keys; the ssh rsa prefix is necessary for the key to work.

    0 讨论(0)
提交回复
热议问题