We feel quite handicapped not being able to run commands on our remote Linux server, this is where SSH comes in handy. Applications like the c-panel, give you control but it’s not quite enough to do custom and ad-hoc tasks. The power of Linux comes when you have access to the Shell.
The perfect tool:
SSH ( Secure SHell) is a protocol that enables us to access the remotely connected Server. It is an essential part of a Linux server and allows you to run commands, transfer files and create VPN over the internet. It provides the perfect control over the server and gives use power of bash shell to handle it remotely. It also allows you to graphical applications, mount drives and share screen remotely.
SSH client comes installed in almost all of the Linux Distributions. SSH server needs to be on your server to make it work. It is really simple to install it on Linux system. There are a number of GUI applications which also provides an interface to it but GUI is not really required. The following provides you commands to install it on Debian-based or RPM-based Linux system.
Ubuntu or any Debian-based distribution
$ sudo apt-get install openssh-server openssh-client
Redhat or RPM-based distributions
# yum -y install openssh-server openssh-clients
Starting and stopping ssh service:
You might want to turn off your service when you don’t want anyone to login to your server or for some security reason. Here is a quick way to do that on Linux
$ sudo service ssh stop $ sudo service ssh start
A bit of configuration:
You do not need to configure it for first use. But the following provides you with a set of tweaks and configurations. You can enable/disable root login through the configuration file for security purpose, change service port ( default is 22), enable/disable empty password login and there are a number of other configurations you can check.
$ sudo vi /etc/ssh/sshd_config
Putting SSH to the test:
Now we are ready to connect to our server. To connect to the server you need to provide the username of any of the users available at your server followed by `@` and the ip address or the domain name of your server.
$ ssh [email protected]_address_or_domain_name
Viola! enter the password when prompted and you have access to the Server. Once you are logged in, you are provided with the bash shell.
Let’s go through an Example:
We have a server connected at 192.168.1.104 and we have a user account on that server with username “j”. And now to ssh into my server here is what i would do.
- Open terminal and enter command ssh [email protected]
- I will be prompted with a message like
The authenticity of host ‘192.168.1.104 (192.168.1.104)’ can’t be established.
ECDSA key fingerprint is 50:fc:87:46:4e:68:50:dd:77:9d:ca:ed:ec:37:4a:5b.
Are you sure you want to continue connecting (yes/no)?
I’ll type yes to proceed. This message comes the first time you login to a server using ssh.
- An finally I’ll be asked for the password.
For a detailed information about switches and configuration options have a look at the man-page(manual).
$ man ssh