• Linux - No .ssh/authorized_keys File

If you want to save time and increase security logging in as root then you can use SSH Keys. First you need to create a /root/.ssh directory with permissions 700. Within that directory you create an authorized_keys file with permissions of 600 and then run restorecon -r /root/.ssh - e.g.

mkdir -m 700 /root/.ssh
echo "your key here" > /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
restorecon -r /root/.ssh

For security reasons it would be better to create a new user and login as that then use sudo to gain root access.
If you choose to go the root-only method then it's advisable to change /etc/ssh/sshd_config so that PermitRootLogin is without-password as this stops root from logging in without the public key.

Alternatively on some servers you can just run ssh-keygen as root to create the directory with the correct permissions.


This article was last modified: Aug. 30, 2018, 3:01 p.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top