☰ Categories

Linux: Setup a new user and their public key

Prerequisite: openssh-server Installed

_______________________________________

useradd username -m -d /home/username –shell /bin/bash

mkdir /home/username/.ssh

chmod 700 /home/username/.ssh

echo “public_keyofuser” > /home/username/.ssh/authorized_keys

chmod 600 /home/username/.ssh/authorized_keys

chown username:username /home/username/.ssh/ -R