Hands-on lab – configuring whitelists within sshd_config

This lab will work on any of your VMs. Follow these steps:

  1. On the VM that you wish to configure, create user accounts for Frank, Charlie, and Maggie. On Ubuntu, do the following:
sudo adduser frank
. . .

On CentOS, do the following:

sudo useradd frank
sudo passwd frank
. . .
  1. Create the webadmins group and add Frank to it:
sudo groupadd webadmins
sudo usermod -a -G webadmins frank
  1. From either your host machine or from another VM, have the three users log in. Then, log them back out.
  1. Open the /etc/ssh/sshd_config file in your favorite text editor. At the bottom of the file, add an AllowUsers line with your own username, like so:
AllowUsers donnie
  1. Then, restart the SSH service and verify that it has started correctly:
For Ubuntu:
sudo systemctl restart ssh
sudo systemctl status ssh

For CentOS:
sudo systemctl restart sshd
sudo systemctl status sshd
  1. Repeat step 3. This time, these three kitties shouldn't be able to log in. Open the /etc/ssh/sshd_config file in your text editor. This time, add an AllowGroups line to the bottom of the file for the webadmins group, like so:
AllowGroups webadmins
  1. Restart the SSH service and verify that it started properly.

From either your host machine or another VM, have Frank try to log in. You'll see that even though he's a member of the webadmins group, he'll still be denied. That's because the AllowUsers line with your own username takes precedence.

  1. Open sshd_config in your text editor and remove the AllowUsers line that you inserted in step 4. Restart the SSH service and verify that it started properly. 
  2. Try to log into your own account, and then try to log into the accounts of all the other users. You should now see that Frank is the only one who is allowed to log in. The only way that any of the other users can now log into the VM is from the VM's local console.
  3. Log into your own account at the VM's local console. Delete the AllowGroups line from sshd_config and restart the SSH service.

You've reached the end of the lab – congratulations!

You've just seen how to configure a whitelist on the daemon level, using the SSH daemon's own configuration file. Next, we'll look at configuring whitelists at the network level.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.253.152