How to Add SSH Key for a New User on VPS (Ubuntu/Debian)

 

How to Add SSH Key for a New User on VPS (Ubuntu/Debian)

You can allow other users to access your VPS securely by adding their SSH public key. This method works for Ubuntu, Debian, and similar Linux OS.

Prerequisites

  • VPS with root SSH access.

  • SSH Key from the user you want to add (public key file).

  • The user must exist on the VPS. (You can create with: adduser username)


Steps to Add SSH Key for a User

1. Switch to Root

Login to your VPS as root:

ssh root@your_server_ip

2. Create .ssh Directory for the User

Replace username with the actual username:

mkdir -p /home/username/.ssh
chmod 700 /home/username/.ssh
chown username:username /home/username/.ssh

3. Add Public Key to authorized_keys

Paste the user's public key into:

nano /home/username/.ssh/authorized_keys
  • Paste the public key here.

  • Save and exit.

chmod 600 /home/username/.ssh/authorized_keys
chown username:username /home/username/.ssh/authorized_keys

4. Test Login as User

From the user's system:

ssh username@your_server_ip

5. (Optional) Disable Password Login for All Users

To enforce SSH key login globally, follow: Disable Password Login on VPS (Ubuntu/Debian)


Notes

  • Make sure the .ssh directory and authorized_keys file have correct permissions.

  • If the user can't login, check file ownership and SSH logs.


Related Articles


WHMCS Knowledgebase Title:

How to Add SSH Key for a New User on VPS (Ubuntu/Debian)

SEO Meta Description:

Learn how to add an SSH key for a new user on Ubuntu/Debian VPS to allow secure key-based access. Step-by-step guide.


Do you want me to combine all 3 articles into HTML-ready code blocks for WHMCS upload?

  • ubuntu ssh key, add ssh key new user, ssh authorized_keys, add user ssh access, debian ssh key, linux ssh key setup, vps ssh user access, secure ssh login
  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

How to Request an rDNS (PTR) Update

If you need to update the rDNS (PTR) record for your VPS or dedicated server, please follow the...

Requesting mail access (Port 25)

By default, port 25 is blocked on all servers for outgoing email to prevent spam and abuse. If...

How to Setup SSH Key Authentication on VPS (Ubuntu/Debian)

  How to Setup SSH Key Authentication on VPS (Ubuntu/Debian) Secure your VPS by logging in with...

How to Disable Password Login on VPS (Ubuntu/Debian)

How to Disable Password Login for VPS (Ubuntu/Debian) Disable password login and enforce SSH key...

Powered by WHMCompleteSolution