I'll answer your questions one by one ;-).
How to delete root password
Bevor you do anythink like that you need another user, that has all rights for sudo! On Ubuntu or Debian the user has to be in the group admin. Login with that user via ssh and try to gain root access with sudo -i
. I it worked you can continue with deactivating login for root with passwd -l root
and you're done.
Access server without password
It is possible to access server with an ssh-keypair. Thats easy and in the most cases more secure than an normal password. First you have to generate such an keypair on your Client PC. If you are using a Linux/Unix you can do this with ssh-keygen -t rsa
. It is recommend to lock this keypair with a password, so only you can use them! Most Desktop-Enviroments like Gnome, Unity and Kde are able to unlock that ssh-key automatically after you unlocked your keyring/wallet.
Now you need to deploy your public key (default ~/.ssh/id_rsa.pub) on your server by adding it to the file * ~/.ssh/authorized_keys * on your server. You can do this manual or with the command ssh-copy-id user@server
.
If a login with your key was successful you can do more for your security by disabling password login for ssh. To archive that you need to change the following line in the file /etc/ssh/sshd_config PasswordAuthentication yes
to PasswordAuthentication no
and restart the ssh-server.
Do I only need to use sudo?
No, but it is recommend! But it depends on the way you use your server. If you are the only user, that have access to your server than it is not really important what you choose, but if there are more than one user sudo make a lot more sense, because you don't have to share your root password to gain root or privileged access. If you decide, that one of the user should not have root access anymore, you only need to remove the sudo privileges instead of changing the root password and sharing it again with everybody. But not everything can be done nicely with sudo.