Ubuntu Server 16.04 Enable SSH and connect

If you want to connect to Ubuntu Server 16.04 you need to enable SSH. You can enable it during installation of Ubuntu Server. When you are asked for installing software like LAMP, Mail and OpenSSH.

If you missed this step then you can do it later by this steps:

Ubuntu Server 16.04 install openSSH

  • login on your server
  • install openssh
sudo apt-get install openssh-server
  • customize the connection
  • change port
  • permissions
  • at the end restart the service to apply the changes
sudo nano /etc/ssh/sshd_config
sudo service ssh restart
  • check the service status
sudo service ssh status

Ubuntu Server 16.04 connect with SSH

  • check the your IP address by
ifconfig

the IP of the server will be used in next command.

  • connect to Ubuntu server by:

  • connecting to 192.168.100.1 with user on port 22

ssh 192.168.100.1 -l user -p 22
  • connecting to 192.168.100.1 no login on port 222
ssh 192.168.100.1  -p 222

on unsuccessful setup or missing OpenSSH you will get:

ssh: connect to host 192.168.100.1 port 222: Connection refused

and in case of success you will be asked if you accept Host key.

The authenticity of host '[192.168.100.1]:22 ([192.168.100.1]:22)' can't be established.
ECDSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX.
Are you sure you want to continue connecting (yes/no)? 

Press yes and you are ready to use your Ubuntu server via SSH.

Note

If you get:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/user/.ssh/known_hosts:12
  remove with: ssh-keygen -f "/home/user/.ssh/known_hosts" -R 192.168.100.1
ECDSA host key for 192.168.100.1 has changed and you have requested strict checking.
Host key verification failed.

then you can remove it by :

ssh-keygen -f "/home/user/.ssh/known_hosts" -R 192.168.100.1

or you can simply change the connection port to 222 and restart the service.