Introduction
Secure Shell (SSH) is a protocol used to log in securely from a remote host to another system over an unsecured network. The password is encrypted when trying to log in to a remote host.
This guide explains how to set up SSH on a newly installed Ubuntu Server 16.04.2 and connect to it from a host machine using the terminal.
Prerequisites
- A newly installed Ubuntu Server 16.04.2.
- A host machine from which you are trying to access the remote machine.
- Sufficient privileges to install packages on the Ubuntu server.
Implementation
In this scenario, we have a Mac OS X host from which we are trying to access a remote Ubuntu server through the terminal.
Step 1: Perform an Update on the Server
Run the following command to update the package information on the server:
apt-get update
Step 2: Install OpenSSH Server
Install the OpenSSH server package by running the following command:
sudo apt-get install openssh-server
This installs the SSH server required to accept remote SSH connections.
Step 3: Connect to the Ubuntu Server
Open a terminal on the host machine and use the following command:
ssh username@hostname
You can also connect using the server’s IP address:
ssh username@hostip
For example:
ssh serveradmin@192.168.x.x
A connection is now established to the Ubuntu Server.
Troubleshooting SSH Connection Issues
If SSH is not installed or the SSH service is not running, you may receive an error when trying to connect to the server.
For example:
ssh: connect to host hostname.tld port 22: Connection refused
When trying to check the SSH service using:
service sshd status
you may receive:
Status: unrecognised service
This indicates that the SSH service is not installed or is not available under the specified service name.
Conclusion
Following the above steps, you can install OpenSSH Server on a newly installed Ubuntu 16.04.2 server and establish a remote SSH connection from a host machine. The SSH connection allows you to securely manage the Ubuntu server remotely.
FAQs
1. What is SSH?
SSH (Secure Shell) is a protocol used to securely access and manage a remote server over a network.
2. How do I install SSH on Ubuntu?
Install the OpenSSH server using:
sudo apt-get install openssh-server
3. How do I connect to an Ubuntu server using SSH?
Use the following command:
ssh username@hostip
4. What does “Connection refused” mean when using SSH?
It generally indicates that the SSH service is not accepting connections on the specified port, which may occur if the SSH server is not installed or running.
5. What is the default SSH port?
The default SSH port is 22.
6. How can I check the SSH service?
On Ubuntu, you can check the SSH service using:
service ssh status
Related Articles
Install Jenkins on Ubuntu 16.
Learn how to install and configure Jenkins on an Ubuntu 16 server for CI/CD automation. Read the Jenkins installation guide.
Add Exim Service to Fail2Ban on Ubuntu
Learn how to configure Fail2Ban to monitor Exim authentication logs and block repeated failed connection attempts. Read the Exim and Fail2Ban guide
Talk to our experts
Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team here.