Setup SSH security on a Linux machine
Enable key-based authentication
First, enable key-based authentication. It is much more secure than using passwords. Find out how to do so here:

Disable password authentication and SSH as root
Edit sudo nano /etc/ssh/sshd_config and find the following lines. If they are commented with a #, un-comment them by deleting the # and ensure they have these values. If any of these line doesn't exist in your file, add it to the end of file.
PermitRootLogin no
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM noReload the SSH service
/etc/init.d/ssh reloadFinally, test the config by trying to SSH from a machine with no authorized key. Normally if no key is detected you will be prompted for a password, but in our case it should deny access.
Change the SSH port
Edit the config file sudo nano /etc/ssh/sshd_config and find this line. Normally it would be commented out like this:
#Port 22Un-comment the line and and change it to something else. Eg.
Port 6543Reload the SSH service
/etc/init.d/ssh reloadTest your new config:
ssh user@host -p 6543