Skip to content

Instantly share code, notes, and snippets.

@janus57
Last active October 5, 2019 09:18
Show Gist options
  • Save janus57/df26c7df3fa9bc4f26b144bdaf80f4b8 to your computer and use it in GitHub Desktop.
Save janus57/df26c7df3fa9bc4f26b144bdaf80f4b8 to your computer and use it in GitHub Desktop.
add public key

Check sshd_config for openssh

First open the "sshd_config" config file (/etc/ssh/sshd_config) en check these lines :

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
AuthorizedKeysFile  .ssh/authorized_keys .ssh/authorized_keys2

AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 ⇒ need to be uncommented

After that restart sshd service : systemctl restart sshd.service

Access root with public key

If /root/.ssh doens't existe create it : mkdir /root/.ssh and then create the file "authorized_keys" file : touch /root/.ssh/authorized_keys

If /root/.ssh existe, then check if the "authorized_keys" file exist : ls -alh /root/.ssh/authorized_keys

And now put the public key inside this file and you can access your server with ssh key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment