Skip to content

Instantly share code, notes, and snippets.

@ngtrieuvi92
Last active July 2, 2020 18:07
Show Gist options
  • Select an option

  • Save ngtrieuvi92/952678665ecf608e96c9fb2829659609 to your computer and use it in GitHub Desktop.

Select an option

Save ngtrieuvi92/952678665ecf608e96c9fb2829659609 to your computer and use it in GitHub Desktop.
Adduser with sudo permission
#!/bin/bash
# I. Run this command on your server
# 1. Create new User
adduser your_user
# 2. Add to sudo group
sudo usermod -aG sudo your_user
# 3. Allow to use sudo without password
echo 'your_user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# II. Run this command on your compute
# 1. Set authorized_keys for your_user to allow ssh with ssh_key, your_private_key and your_public_key should at the same directory
ssh-copy-id -i your_private_key your_user@your_server_ip
# 2. Add infomation to ssh config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment