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_configFind and update the following lines
PermitRootLogin yes
PasswordAuthentication yesRestart SSH service
systemctl restart sshThis 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/.sshAdd your public key to the authorised keys. Paste the public key here.
nano /root/.ssh/authorized_keysSet permissions.
chmod 600 /root/.ssh/authorized_keysEnable public key authentication in /etc/ssh/sshd_config by setting the following permission.
PubkeyAuthentication yesRestart SSH.
systemctl restart ssh
0 Comments