HOWTO - Create New SSH User
Create a New SSH User:
Create a new user on your server for the person who needs to SSH in. You can do this using the
addusercommand. For example:
Grant Sudo Privileges (Optional):
If the user needs administrative privileges, you can add them to the sudo group. This allows them to execute commands with superuser privileges. Use the
usermodcommand:
Provide Public Key:
- Ask the user to generate an SSH key pair on their local machine (if they haven't already) using the
ssh-keygencommand. They will have a private key (usually namedid_rsa) and a public key (usually namedid_rsa.pub).
- Ask the user to generate an SSH key pair on their local machine (if they haven't already) using the
Send Public Key to You:
- Have the user send you their public key. This is typically the content of the
id_rsa.pubfile. They can use a secure method like encrypted email or a secure messaging platform.
- Have the user send you their public key. This is typically the content of the
Add Public Key to Authorized Keys:
On your server, navigate to the home directory of the new user and create a
.sshdirectory if it doesn't exist:
authorized_keys file:Test the Setup:
Have the user try to SSH into the server using their private key:
Replace
/path/to/private_keywith the actual path to their private key andyour_server_ipwith the IP address or domain of your server.
This way, you maintain better control over access to your server, and each user has their own set of keys for authentication. It's a good security practice as it allows you to grant or revoke access for individual users without affecting others.
Comments
Post a Comment