Ubuntu guide: https://help.ubuntu.com/community/SSH/OpenSSH/Configuring
sudo apt-get install openssh-server
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults
sudo chmod a-w /etc/ssh/sshd_config.factory-defaults
sudo gedit /etc/ssh/sshd_config
Change the PasswordAuthentication to "no" and "Port" to another one of your choosing
For restarting the daemon, use one of these:
sudo restart ssh
sudo systemctl restart ssh
sudo service ssh restart
Portforward help: http://portforward.com/
Ubuntu guide: https://help.ubuntu.com/community/SSH/OpenSSH/Keys
mkdir ~/.ssh
chmod 700 ~/.ssh
Command to create a new key:
cd ~/.ssh
ssh-keygen -t rsa -b 4096
It will ask you for a name, use a name that shows which device is going to connect to this server. Ex: id_nexus5
Install the PUBLIC key of what you just created in your authorized_keys
cp authorized_keys authorized_keys_Backup
cat id_nexus5.pub >> authorized_keys
Copy the PRIVATE key over with whatever means necessary (the id_nexus5 file)
Use it in the ~/.ssh/config
Host Server
HostName www.server.example or IP
Port 1234
IdentityFile ~/.ssh/id_nexus5
ssh Server