Inadvertently removing .ssh/authorized_keys , is it a serious mistake?

The ~/.ssh/authorized_keys file contains a list of public keys. It allows everyone who owns a private key matching one of those to connect to this machine and get remote access under this user account (the tilde ~ at the front of the path signifies that this file is under the current user's home directory).

On the server (the machine you want to connect to):

If you deleted this file, nobody will be able to authenticate under this user account using their private keys. Password authentication would still work, unless it was disabled.

You'd have to regenerate the file and add all the public keys to which you want to grant access using the public key authentication method again.

On the client (the machine you want to connect from, i.e. your local machine):

Here you do not need an authorized_keys file, because you do probably not want to authorize any keys and grant them remote access to your local computer. It should be empty or deleted.

On the client, you only need the private key files which are authorized on the server (i.e. which have their corresponding public keys in the authorized_keys file on the server), and optionally an appropriate config and known_hosts file.


Yes, you removed the whole file. To recreate it all users have to copy their ssh-keys on the server agein. You can use

ssh-copy-id [email protected]

If you don't want to remove all keys, edit the file and remove only the lines next time.

Tags:

Ssh