Public Key Authentication fails or fails to register

PROBLEM DESCRIPTION


After creating a private key in Xshell, you register the public key in the server according to the manual, but you get a message stating that the key is unregistered.


RESOLUTION


  1. Paste the public key string into the user's public key file $HOME/.ssh/authorized_keys.
    The location of the SSH server's public key file is defined in sshd_config.
    You must register the public key string on the server, not the private key string.


  2. Only grant permissions to the '.ssh' directory and the 'authorized_keys' files to the user.
    If there are too many granted permissions, modify the permissions with the following command.

    $ chmod go-rwx ~/.ssh ~/.ssh/authorized_keys
  3. In rare cases, the owner of the user's home directory may differ from the connection account.
    In this case, you must make the home director's owner the same as the connection account.

    chown `whoami` $HOME