This article describes how to enable secure shell (SSH) public key authentication.
Steps:
- Log in to the server.
- Confirm that the user exists-
‘getent passwd <username>’ - Check the value assigned to the AuthorizedKeysFile parameter in the /etc/ssh/sshd_config file to locate the specific file where the key is stored-
‘grep AuthorizedKeysFile /etc/ssh/sshd_config’
Note- By default, the location is ~/.ssh/authorized_keys in the user’s primary home directory. - Navigate to the user’s home directory.
‘cd /directory-path’
Note- Replace “directory-path” with the path to the user’s home directory. - For the .ssh/ directory, check permission levels. It should have 0700 permissions and be possessed by the user.
‘ls .ssh’- In the event that the directory does not exist, create it and configure the permissions to 0700.
‘mkdir -m 700 .ssh’ - If the directory exists, you can set possession distinctly-
‘chmod 700 .ssh/’
‘chown -R username:username /path/to/home/.ssh’
- In the event that the directory does not exist, create it and configure the permissions to 0700.
- Shift to .ssh/ directory and authorized_keys file-
‘‘‘cd .ssh/
vim authorized_keys
ll’’’ - Append the SSH Public Key to the end of the authorized_keys file.
‘vim authorized_keys’ - Modify permissions to 600 and confirm appropriate ownership of the file-
‘chmod 600 authorized_keys’
‘chown -R username:username authorized_keys’
This way, you can enable secure shell (SSH) public key authentication. If you get into any problem, seek help from our technical support team at your earliest.