0

Linux noob here.

I have a VM on Google Cloud. Have Debian on it. I used to connect to it through Google Cloud's ssh client.

In file /etc/ssh/sshd_config i changed the value:

PermitRootLogin prohibit-password
PasswordAuthentication no

to

PermitRootLogin yes 
PasswordAuthentication yes

Now I'm stuck on Transferring SSH keys to the VM. When I want to ssh through another client It asks me of a password, which I do not know.

I think I made a silly mistake. Is there anyway I can revert that change or ssh ?

EDIT: I'm tasked with setting up our DevOps pipeline. In this case, as a linux noob, 'I locked the door and slid the key under it'. It's no problem since the docs I produced helped me do a weeks work in an hour. And I already was planning to do all the process from scratch to verify. Still I won't remove the old locked VM, let it stay passive. Someday I may return and try your advices. Thanks for answers.

2 Answers 2

3

If there's important data on the VM which you need, you can mount the disk of your VM on a new VM as a secondary disk. Then you can SSH to this new VM and copy any required data from the old disk. Or you could also try to revert the sshd_config changes that you made and start the old disk as individual VM again.

This post from Stackoverflow has detailed instructions how to mount the VM disk to another VM: https://stackoverflow.com/questions/47399105/how-to-reset-password-or-set-single-user-mode-for-serial-console-logon

1
  • 1
    This is a really good answer and actually I think it should be accepted instead of mine. Commented Sep 18, 2019 at 9:50
1

On it own PermitRootLogin yes should not disable ssh-keys login.

Using root for ssh is really bad practice. Properly you should:

  1. Create custom user
  2. Add him to administrators/wheel group, so he can use sudo
  3. Connect to this user with SSH

If the damage is already done, so you can not connect anymore via normal SSH, try to use the Google Console, or whatever tool your provider offers. Unfortunately you can not revert it without accessing the server.

This issue requires more debugging on the server side. Maybe you can try logging in using some specific private ssh key. Have you tried reading the ssh command verbose output?

If you can not connect to the server without ssh, then I am afraid, but the VM is lost.

2
  • 1
    I too think I lost it. I'll get back to your answer.
    – Doruk
    Commented Sep 17, 2019 at 12:26
  • Life is hard. Usually the tools from the VM provider are offered to solve issues like this. Commented Sep 17, 2019 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .