Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2018-06-25 21:06:49
Size: 775
Editor: PieterSmit
Comment:
Revision 4 as of 2018-06-25 21:16:12
Size: 883
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
= Add ssh user to a Linux (ubuntu/debian) server, that only has ssh key access = = Add ssh user to a Linux (ubuntu/Debian) server, that only has ssh key access =
Line 7: Line 7:
 * Procedure addapted from [[https://unix.stackexchange.com/questions/210228/add-a-user-wthout-password-but-with-ssh-and-public-key]]
   1. create variable with username {{{
 * Procedure adapted from [[https://unix.stackexchange.com/questions/210228/add-a-user-wthout-password-but-with-ssh-and-public-key]]

1. create a variable with username {{{
Line 11: Line 12:
Line 15: Line 17:
      }}}
   1. 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
Line 22: Line 20:
   1. 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

      }}}
   1. if sudo required add user to the group {{{
sudo usermod -aG sudo $username
     }}}

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

    1. create a variable with username

      export username='tom'
    2. 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
    3. 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
    4. if sudo required add user to the group

      sudo usermod -aG sudo $username

...


CategoryLinux

Linux/AddSshUserKeyOnly (last edited 2018-06-25 21:16:12 by PieterSmit)