If you’re running Linux devices like Raspberry Pis or VMs at home then managing them is easier if you can SSH into them as the root user. Though this is not always allowed by default.
Open the SSH config file
nano /etc/ssh/sshd_config
Find and update the following lines
PermitRootLogin yes
PasswordAuthentication yes
Restart SSH service
systemctl restart ssh
This will allow root access using a username and password, however an easier and more secure method is to use SSH keys.
If you’re on Windows you can find your public key at C:\Users\YourUsername.ssh\id_rsa.pub
. Open the key file with notepad (or equivlent). If no public key exists you can create one with.
ssh-keygen -t ed25519 -C "[email protected]"
Log into your remote environment and create a new SSH folder.
mkdir -p /root/.ssh && chmod 700 /root/.ssh
Add your public key to the authorised keys. Paste the public key here.
nano /root/.ssh/authorized_keys
Set permissions.
chmod 600 /root/.ssh/authorized_keys
Enable public key authentication in /etc/ssh/sshd_config by setting the following permission.
PubkeyAuthentication yes
Restart SSH.
systemctl restart ssh
0 Comments