Wednesday, December 25, 2019

Amazon AWS Linux - Enable password authentification only for certain user

1. Add new user part of sudoers:
sudo su
useradd dtech


2. Create password:

passwd dtech
 

3. Make sure it has sudo rights:
cd /etc/sudoers.d/
touch dtech_other_sudoers
chmod 440 dtech_other_sudoers
vi dtech_other_sudoers

dtech  ALL=(ALL)       NOPASSWD: ALL

# This comment is here to have new line at end of file

4. Enable password authentification:
vi /etc/ssh/sshd_config


5. Add following lines to the very end of the file:
Match User dtech
    PasswordAuthentication yes

  

6. Restart sshd service
service sshd restart


7. Test and you shall now get password prompt only for your user:
ssh dtech@35.171.158.153
dtech@35.171.158.153's password:
Last login: Wed Dec 25 22:17:05 2019

No comments:

Post a Comment