If you don't have SSH installed then run
sudo apt-get install openssh-client openssh-server
sudo yum -y install openssh-clients openssh-server
To make things easier login with root using
su -as most of the commands need root privileges.
Or you can just put
sudoin front of all of these commands.
Firstly make a backup of the file we will be working with in case you want to return to your original setup.
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
The line we are going to add to the file is
AllowUsers "Put users here separated by spaces"
So add the line and then after it a comment for future reference something like only allow SSH access with these users
Now we need to restart the sshd service
If you are running Ubuntu/Debian/Mint run
service ssh restart
If you are running RHEL/Fedora/Centos
service sshd restart
If you are currently logged in over ssh this will close the connection and a new one will be created.
Now if you try and login with a user not specified in the sshd config file
ssh "blocked user"@"ip of pc"
You will not be able to
But if you try to login with a user specified in the sshd config file
ssh "specified user"@"ip of pc"
You should be able to login as usual.