atistrcsn
6/14/2018 - 6:40 AM

Ubuntu new ssh user

with home directory

#!/bin/sh

NEWUSER=newuser \
&& mkdir -p /home/${NEWUSER}/.ssh \
&& touch /home/${NEWUSER}/.ssh/authorized_keys \
&& useradd -d /home/${NEWUSER} ${NEWUSER} -s /bin/bash \
&& chown -R ${NEWUSER}:${NEWUSER} /home/${NEWUSER}/ \
&& chown root:root /home/${NEWUSER} \
&& chmod 700 /home/${NEWUSER}/.ssh \
&& chmod 644 /home/${NEWUSER}/.ssh/authorized_keys

#usermod -aG sudo ${NEWUSER}