Created
May 16, 2019 00:16
-
-
Save albertogalan/bf98f49269664eff6b2bc47292562ae2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage cat script.sh | ssh HOST | |
MAINUSER=agalan | |
sudo apt-get update | |
sudo apt-get -y install python-simplejson | |
sudo apt install -y openssh-server | |
LINE="%$MAINUSER ALL=(ALL:ALL) NOPASSWD:ALL" | |
FILE=/etc/sudoers | |
grep -qF "$LINE" "$FILE" || echo "$LINE" | sudo tee --append "$FILE" | |
sudo adduser $MAINUSER | |
sudo adduser $MAINUSER admin sudoers | |
#usermod -u 1009 ubuntu | |
#groupmod -g 1009 ubuntu | |
sudo usermod -u 1004 $MAINUSER | |
sudo groupmod -g 1004 $MAINUSER | |
sudo mkdir -p /home/$MAINUSER/.ssh | |
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDaWulObziluJLzVk7tmEDfkAKpCHEmp4AFvnQVhh6Yof40s2yfz1h/bMCfBstg+jLz86K99DV/tnIDtxXRx2GfGVz11l/BSuhStUDu9RKxZYN4DhMzc31/vwIWWP/P4vnJX96+JlcfF+0hbXmqfHhlcJACT7nRFuQrtVs+REAyJG/3ZuWNH1jvSKmXJYRj+CeCl0hElYtf+bF3JCEnmXl+ezUQcIXyhJ3loPhuEoGPHjHP8gZmiSjUn5SHaLkH1JPt6A/DvpxyPHdFmopL/HxFJEPxF4m5hCLleM2do3r5Owe4lmmOGgANkRLhS8b/Mmqe0mjOno9gYGYcnJ4iaPa9 $MAINUSER@neolearn" | sudo tee -a /home/$MAINUSER/.ssh/authorized_keys | |
sudo chmod 600 /home/$MAINUSER/.ssh/authorized_keys | |
sudo chown $MAINUSER:$MAINUSER /home/$MAINUSER/.ssh/authorized_keys | |
sudo adduser $MAINUSER sudo | |
sudo service sshd restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment