0

Ubuntu 18 (I think).

I was being able to login to a machine via SSH using my public key. Later I edited "/etc/ssh/sshd_config" so I could give password access to a third-party user I just created. I changed:

PasswordAuthentication no

Into:

PasswordAuthentication yes
AuthenticationMethods publickey,password

I thought this would allow me to use the publickey as default authentication method (so I could still log in as usually), else being prompted for a password (for the new user).

But it turns that it's now asking for BOTH things: publickey and password. I don't know the password, as I was granted access using the public key, so I can't access the website anymore. Additionally, the third party user can't access either, as no public key was configured for him.

How could I re-gain access again??? I've asked the original sysadmin, but doesn't seem able to help. Shouldn't this sysadmin be able to login the machine using the original root password created when he first setup the machine??? (with the main objective or resetting or fixing "/etc/ssh/sshd_config", then restarting the SSH server)

5
  • Comment out AuthenticationMethods and it should default to the remaining items in the system - password authentication and pubkey auth if enabled with PasswordAuthentication and PubkeyAuthentication both set to 'yes'. Only set "AuthenticationMethods" if you have multiple methods that have to succeed. – Thomas Ward Feb 11 at 15:08
  • This one of the reason I always advocate that sudo should never be password-less on servers. Especially production machines. Not knowing your own user's password is never a good option. Eitherway, if you don't have physical access to the machine, hosting providers usually always give a recovery option for things like this. You might need to look there. – Dan Feb 11 at 15:10
  • @ThomasWard I guess OP's problem is that they cannot log into the server anymore for commenting out AuthenticationMethods. – Dan Feb 11 at 15:10
  • @Dan if they have contact with the sysadmin who gave them access, they can have the sysadmin make the changes. – Thomas Ward Feb 11 at 15:11
  • I have contact with the sysadmin and he says the system must be deleted and reinstalled, but I wonder how did he manage to setup my "ubuntu" account in the first place (ie, copy my public key to the known hosts so I could access). Couldn't it be teorically possible to enter again using such access to fix the system? – nothingham Feb 11 at 16:57
1

Firstly, Ubuntu does not have a root password by default. The root user is disabled by default, and sudo is how a user in /etc/sudoers or a relevant group gains access to superuser power to execute commands.

If the original administrator does not have access to the system either, then the system is effectively "no longer able to be accessed" and it would require direct system/console access to get in and fix things; if that is unavailable the system would need to be replaced/reformatted/reinstalled.

If the original administrator CAN access the system, then you can ask them to go into /etc/ssh/sshd_config and comment out your AuthenticationMethods line.

1
  • I would like to know as well if the original administrator CAN access the system. Is it possible teorically? I mean: how did the original admin setup the machine and installed my public key in the known hosts file? Can he use the same method again to enter and fix the config file? – nothingham Feb 11 at 16:54

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.