shntnu
1/6/2017 - 1:34 PM

Create user and setup access to login node

Create user and setup access to login node

FULLNAME="Shantanu Singh"
USERNAME=shsingh
sudo bash
useradd -c "${FULLNAME}" -s /bin/bash -m ${USERNAME}
PASSWORD=`openssl rand -base64 6`
echo ${PASSWORD} |  tee -a /home/${USERNAME}/.password 
echo "${USERNAME}:${PASSWORD}" |  chpasswd
mkdir /home/${USERNAME}/.ssh
chmod 700 /home/${USERNAME}/.ssh
cat > /home/${USERNAME}/.ssh/authorized_keys
chmod 600 /home/${USERNAME}/.ssh/authorized_keys
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.ssh
usermod -aG sudo ${USERNAME}


cat > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa