USERNAME=$1
sudo adduser $USERNAME --disabled-password --gecos ""
cd /home/$USERNAME
sudo mkdir .ssh
sudo touch .ssh/authorized_keys
sudo chmod 600 .ssh/authorized_keys
sudo ssh-keygen -b 2048 -t rsa -f /home/$USERNAME/$USERNAME -q -N ""
sudo cp /home/$USERNAME/$USERNAME.pub /home/$USERNAME/.ssh/authorized_keys
sudo chown $USERNAME:$USERNAME /home/$USERNAME/.ssh/
sudo chown $USERNAME:$USERNAME /home/$USERNAME/.ssh/authorized_keys
sudo usermod -aG sudo $USERNAME
sudo passwd $USERNAME
# to scp the private key, lets have it copied here
sudo cp /home/$USERNAME/$USERNAME /home/ubuntu/
cd /home/ubuntu/
sudo chown ubuntu:ubuntu $USERNAME
sudo adduser $USERNAME --disabled-password --gecos ""
cd /home/$USERNAME
sudo mkdir .ssh
sudo touch .ssh/authorized_keys
sudo chmod 600 .ssh/authorized_keys
sudo ssh-keygen -b 2048 -t rsa -f /home/$USERNAME/$USERNAME -q -N ""
sudo cp /home/$USERNAME/$USERNAME.pub /home/$USERNAME/.ssh/authorized_keys
sudo chown $USERNAME:$USERNAME /home/$USERNAME/.ssh/
sudo chown $USERNAME:$USERNAME /home/$USERNAME/.ssh/authorized_keys
sudo usermod -aG sudo $USERNAME
sudo passwd $USERNAME
# to scp the private key, lets have it copied here
sudo cp /home/$USERNAME/$USERNAME /home/ubuntu/
cd /home/ubuntu/
sudo chown ubuntu:ubuntu $USERNAME
No comments:
Post a Comment