781
Comment:
|
884
|
Deletions are marked like this. | Additions are marked like this. |
Line 8: | Line 8: |
Line 11: | Line 12: |
Line 15: | Line 17: |
Line 16: | Line 19: |
Line 20: | Line 24: |
Line 21: | Line 26: |
1. if sudo required add user to the group {{{ sudo usermod -aG sudo $usnername }}} |
Add ssh user to a Linux (ubuntu/Debian) server, that only has ssh key access
Procedure adapted from https://unix.stackexchange.com/questions/210228/add-a-user-wthout-password-but-with-ssh-and-public-key
create a variable with username
export username='tom'
create the user and add public key to authorized_keys file
sudo useradd -m -d /home/$username -s /bin/bash $username sudo mkdir /home/$username/.ssh sudo vim /home/$username/.ssh/authorized_keys
fix permisions for file and directory
sudo chown -R $username:$username /home/$username/.ssh sudo chmod 700 /home/$username/.ssh sudo chmod 600 /home/$username/.ssh/authorized_keys
if sudo required add user to the group
sudo usermod -aG sudo $usnername
...