Digital oceans create new user ssh
To create a new user and set up SSH access on a DigitalOcean droplet, you can follow these steps:
Step 1: Log in to your DigitalOcean account and access your droplet
- Go to your DigitalOcean account and click on the "Droplets" tab.
- Select the droplet you want to manage and click on the "Access" tab.
- Click on the "SSH" button to access your droplet via SSH.
Step 2: Create a new user
- Once you're logged in, you can create a new user using the
adduser
command:sudo adduser newuser
Replace
newuser
with the desired username.
Step 3: Set a password for the new user
- Set a password for the new user using the
passwd
command:sudo passwd newuser
Follow the prompts to set a password for the new user.
Step 4: Add the new user to the sudo group
-
To give the new user sudo privileges, add them to the
sudo
group:sudo usermod -aG sudo newuser
Step 5: Create a new SSH key for the new user
-
To set up SSH access for the new user, you'll need to create a new SSH key pair. You can do this using the
ssh-keygen
command:sudo ssh-keygen -t rsa -b 4096 -C "[email protected]"
Replace
[email protected]
with the email address you want to associate with the new user.
Step 6: Copy the public SSH key to the new user's home directory
-
Copy the public SSH key to the new user's home directory:
sudo cp ~/.ssh/id_rsa.pub /home/newuser/.ssh/authorized_keys
Step 7: Change the ownership of the authorized_keys file
-
Change the ownership of the
authorized_keys
file to the new user:sudo chown newuser:newuser /home/newuser/.ssh/authorized_keys
Step 8: Test SSH access with the new user
-
Try connecting to your droplet using SSH with the new user:
ssh newuser@your-droplet-ip
Replace
your-droplet-ip
with the IP address of your DigitalOcean droplet.
That's it! You should now be able to log in to your DigitalOcean droplet using the new user's credentials.