I am new to set up SSH Keys on Ubuntu 16.04.
I was looking for an authorized key to remove named anne
but I think I deleted the whole authorized_keys
file.
mike@mike-thinks:~$ rm /home/mike/.ssh/
authorized_keys id_rsa id_rsa.pub known_hosts
mike@mike-thinks:~$ rm /home/mike/.ssh/authorized_keys
Is it serious mistake? If yes how to regenerate them? Meanwhile I did that :
mike@mike-thinks:~/.ssh$ touch ~/.ssh/authorized_keys
mike@mike-thinks:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
mike@mike-thinks:~/.ssh$ chmod 600 ~/.ssh/authorized_keys
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 appropriateconfig
andknown_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
If you don't want to remove all keys, edit the file and remove only the lines next time.