Skip to content

Instantly share code, notes, and snippets.

@nrjpoddar
Created February 27, 2018 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrjpoddar/647d6b8414f1b0656166e32ce8581a35 to your computer and use it in GitHub Desktop.
Save nrjpoddar/647d6b8414f1b0656166e32ce8581a35 to your computer and use it in GitHub Desktop.
sudo EDITOR=vim visudo
# Change the following in /etc/sudoers:
# %sudo ALL=(ALL:ALL) ALL -> %sudo ALL=(ALL:ALL) NOPASSWD:ALL
sudo mkdir -p /home/mynewuser/.ssh
sudo adduser --home /home/mynewuser --disabled-password --shell /bin/bash mynewuser
sudo usermod -aG sudo mynewuser
sudo chown -R mynewuser:mynewuser /home/mynewuser/
sudo chmod 700 /home/mynewuser/.ssh
sudo touch /home/mynewuser/.ssh/authorized_keys
sudo chmod 644 /home/mynewuser/.ssh/authorized_keys
# Add the public key in /home/mynewuser/.ssh/authorized_keys for
# allowing SSH key based access for user "mynewuser"
@nrjpoddar
Copy link
Author

Adding second user for non-interactively with sudo powers which doesn't require password for login:

sudo addgroup --gid 5432 jenkins
sudo adduser --gecos "" --home /home/jenkins --disabled-password --shell /bin/bash --uid 5432 --gid 5432 jenkins
sudo mkdir -p /home/jenkins/.ssh

sudo cp /home/ubuntu/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
sudo chown -R jenkins:jenkins /home/jenkins/
sudo chmod 700 /home/jenkins/.ssh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment