To add multiple authorized keys for a user in Ubuntu, you can follow these steps:
-
Log in to the Ubuntu machine as the user for whom you want to add the authorized keys.
-
Create a directory named
.ssh
in the user's home directory, if it doesn't already exist. You can do this with the following command:mkdir -p ~/.ssh
-
Change the permissions on the
.ssh
directory to 700 (read, write, and execute for the owner only):chmod 700 ~/.ssh
-
Create a file named
authorized_keys
in the.ssh
directory. You can do this with the following command:touch ~/.ssh/authorized_keys
-
Open the
authorized_keys
file in a text editor. -
Copy and paste each public key that you want to add into a new line in the
authorized_keys
file. -
Save and close the
authorized_keys
file. -
Change the permissions on the
authorized_keys
file to 600 (read and write for the owner only):chmod 600 ~/.ssh/authorized_keys
After completing these steps, the user will be able to log in via SSH using any of the public keys that you added to the authorized_keys
file.
TAGS