0

I recently decided to disable Root Access, to my VPS, via SSH/PuTTy. This being an obvious effort to increase the security of the VPS.

I achieved this by heading into /etc/ssh/sshd_config and performing the following line changes:

  • PermitRootLogin yes to PermitRootLogin no
  • PasswordAuthentication yes to PasswordAuthentication no

I then logged into the VPS, via PuTTy and restarted SSH by placing the following command:

  • service ssh reload

I had no problems with the above but I now wish to regain access Root access to the VPS. I thought it would be as simple as reversing the steps I performed in the /etc/ssh/sshd_config file. Unfortunately, this does not seem to be the case. I assume it is because I need to reload the SSH for any changes to take effect. Something I obviously cannot do, without having access in the first place.

What other options do I have, in allowing myself to regain this Root access?

Solutions to date ...

  1. I assigned bin/bash (chrooted) SSH Access to another user. Logged in via PuTTy, with this user, the tried to reload SHH from here. Unfortunately, the command was not recognised when logged in with this user.
Craig
  • 145
  • 1
  • 1
  • 6
  • Use `sudo` like everyone else? – Michael Hampton Aug 14 '20 at 21:55
  • Just tried `$ sudo -u root service ssh reload`. Unfortunately, the response was 'user.xyz is not in the sudoers file.' Is this what you meant by using `sudo` or is there another method? Perhaps I would need to place the `user.xyz` into the sudoers file? Any directive on this, if this is the case, would be appreciated. – Craig Aug 14 '20 at 22:04
  • At least one of your users should already be able to sudo. Usually it's the first user created when the system is first installed. If you don't have any users able to sudo, you'll probably have to use some kind of rescue media to fix the VPS. – Michael Hampton Aug 14 '20 at 22:15
  • Thanks for the suggestion. I just tried logging in, with the first User I created on the VPS. Basically, the 'Admin' Role for the VPS, which has no domain associated with it. Unfortunately, SSH Access is denied to this account. – Craig Aug 14 '20 at 22:39
  • 1
    Login as a regular user then do a simple "su -" and enter your root password. – Brandon Xavier Aug 15 '20 at 08:00

1 Answers1

2

Many VPS providers offer console access to the VPS. There you can login to the system as root and perform any operations that need root privileges.

Check your VPS provider control panel for the option.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Thanks for this information. I have tried to log in, via this method, but my log in details are not recognised at all. I am awaiting a response from them at present. Any other methods would be appreciated. Will update this comment, as soon as I get a response. :-) – Craig Aug 14 '20 at 23:21
  • Do you mean VPS control panel credentials are not recognized or console root credentials? – Tero Kilkanen Aug 15 '20 at 07:52
  • I tried both the VPS Root Login credentials as well as the Login credentials for the Control Panel that is provided by the VPS provider. Unfortunately, neither were successful. – Craig Aug 16 '20 at 01:56