how to turn off password-less login for ssh?

9,551

Solution 1

Disable pubkey authentication on the client where you don't want to use it.

ssh -o PubkeyAuthentication=no your_host

or in your ~/.ssh/config:

Host your_host
  PubkeyAuthentication no

If you want to remove the public key from the server, you need to remove the appropriate line from ~/.ssh/authorized_keys on server.

Solution 2

As

ssh -o PubkeyAuthentication=no your_host

can easily be reverted by anyone who has access to the client to login to your laptob without needing a password at all, it may be a better choice to use a password encrypted private-key for those destinations, where you want to be asked for a password before login.

Share:
9,551

Related videos on Youtube

In78
Author by

In78

Updated on September 18, 2022

Comments

  • In78
    In78 over 1 year

    I had setup password-less SSH login from my desktop to my laptop following the steps here. Now I want to turn off the password-less login so that when I ssh from my desktop to my laptop, it will ask for the password. How do I do it?

  • Jakuje
    Jakuje about 8 years
    Or remote the key entirely. But it is not clear what is the OP intention.
  • In78
    In78 about 8 years
    Can the public key on the laptop(the host) be deleted?
  • In78
    In78 about 8 years
    Can the public key from the server be deleted?
  • cmks
    cmks about 8 years
    yes, it can. the public keys are stored on the host in the file $HOME/.ssh/allowed_keys - one key each line.
  • Jakuje
    Jakuje about 8 years
    Yes. You will remove it the opposite way as you added it there. The file is ~/.ssh/authorized_keys.