0

I can use RSA keys to putty into my centos VPS with no problem. And from there I can use sudo to run commands. But my root password is not working. I wonder if I hosed something while setting up passwordless putty logon.

When I do su whatever neither of my past couple of root passwords work. Using sudo I changed sshd_config to permit:

PermitRootLogin  yes
PasswordAuthentication yes

Then reloaded the sshd service. But couldn't then ssh in as root either. Suggestions?

Update 1 Tried sudo su but the result was

This account is currently not available.

But my user password works with sudo nano /etc/ssh/sshd_config. And I successfully edit that file.

2

Sounds like you don't know your root password, if even su refuses your password.

Hence, what you should do is reset your root password. Having sudo su, run passwd, type in your new passphrase twice when prompted, ...

Now you don't necessarily need to know of your root password. If you're already using some RSA key logging into your VPS, you should be able to authorize that key connecting as root.

And even though: you don't necessarily need to log in as root. If you can sudo from a management user, why would you want your root account to be authorized logging into your SSH server?

Assuming you just want to login using SSH keys, change your sshd_config:

PermitRootLogin without-password
PasswordAuthentication no

Assuming you prefer to prevent root from using SSH, just go with:

PermitRootLogin no
PasswordAuthentication no

If and only if, you're sure you want root password authentication to be allowed over SSH, knowing of your su password, you may consider going with:

PermitRootLogin yes
PasswordAuthentication yes

If you want to make sure root password authentication is disabled system-wide, you could run (as root):

passwd -d

As of your last edit, in regards to sudo su failing with This account is currently not available.: this would indicate your root account shell was changed to something like nologin.

Try this: sudo su -s /bin/bash.

Assuming it did open a root shell, you may then want to change your root shell using chsh.

  • The last suggestion allowed me to do yum update. Thanks! Which is all I was trying to do in the first place when I ran into this problem. Yeah I'm going to change sshd_config back to prevent root with ssh. – Skippy VonDrake Feb 9 '17 at 19:11
  • Just to clarify, I was following update instructions which said su -c 'yum update'. If I just do sudo yum update as the user it worked. – Skippy VonDrake Feb 9 '17 at 21:16
0

Sounds like your root password was changed. Use sudo su to su to root and passwd to change the root password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.