How to use SSH

When we use a program on our computer, we are used to using a graphical interface to be able to manage all its functions. But if we have a data server or a hosting server for our website, we will hardly apply the settings from an interface, since in most cases we will have to type commands from a prompt or terminal to be able to properly administer our server. If the server is located outside our home network (for example on a server offered by a provider, or we are away from home and want to access our personal server) or we want to access it without a graphical interface, we will have to make a secure and encrypted connection in order to send commands from a prompt . In this guide we will show you how to use SSH to send remote terminal commands on any server. Given the difficulty of the topic, we will try to be as clear and simple as possible, so that even a novice user can learn to use SSH to remotely control their server.

How to use SSH

Below you will find how to create an SSH server on Windows and Linux, how to connect to an SSH server from Windows and finally how to connect to an SSH server from smartphones and tablets (from Android and iOS operating system). If we do not know the origin of the SSH service, we refer you to reading the dedicated Wikipedia page.

How to create an SSH server on Windows

If we use Windows 10 on our computer, we can install the OpenSSH module. To do this we open the Start menu at the bottom left, open the Settings app, open the App menu -> Apps and features and finally click on Optional features . On the page that appears, click on Add a feature, scroll through the list of features and then make sure to select the OpenSSH Server item.

At the end of the server installation, we open the Start menu again, search for the Windows PowerShell app, right-click on it and select Run as administrator . In the command line window that appears, we carry out the initial configurations of the SSH server by typing the following commands from the terminal (let's type them one line at a time):
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
Get-NetFirewallRule -Name * ssh *
After starting these commands, the PC with Windows 10 that we are using can accept SSH connections on port 22, using the access credentials configured on the Windows account (we will obviously have to forward this port to the router or modem, so that we can reach it when we are out of the personal network).
Note : if port 22 is not configurable or is not accessible from our network, simply open the file C: \ Windows \ System32 \ OpenSSH \ sshd_config and modify the entry for port 22, setting a port as desired.

How to create an SSH server on Linux

On a Linux server, setting up SSH is much easier, since OpenSSH is well integrated with other system tools. After configuring the machine or server online with Ubuntu (taken as an example in this guide), we open the Terminal app, then type the following command:
sudo apt-get install openssh-server
We confirm where necessary to complete the installation of the OpenSSH server. To start the service immediately, simply run the following command from the terminal:
sudo /etc/init.d/ssh restart
The system will use the user account credentials for access and port 22 to accept connections from the outside.

If we want to change the input port for SSH connections (for the same reasons seen on Windows), just type the command in the terminal:
sudo vi / etc / ssh / sshd_config
From the text editor we navigate through the various options until we find the Port item, so we can configure a new port for SSH connections.

How to connect to an SSH server from Windows

After configuring the SSH server, we can access it from any other Windows 10 PC connected to the Internet by simply opening the Windows PowerShell program and typing the following command from the terminal:
ssh -p portnumber
the command consists of the username ( username ) that requires access, the server name ( servername ) and the port number to contact.

As username, just use that of the user account configured on the server, while as servername we can directly enter the public IP address of the Internet connection used by the server or the domain name (if registered). The default port is 22, but we can change it without problems if the SSH server has been configured with a different port. At each connection, the access password will be requested, coinciding with the password of the system account (or of the administrator account).
If we use other versions of Windows (7 and 8.1) or we want to get more control over the encrypted connection, we suggest you install the free and open source PuTTY program.

With this program we will be able to connect quickly to any SSH server, just enter the username in the Host Name field, configure the port in the Port field, put a check mark on the SSH item and finally click on Open at the bottom.

How to connect to an SSH server from a smartphone or tablet

If we want to control our SSH server from a smartphone or tablet, we recommend installing the free Termius app, available for both Android and iOS.

With this app we will be able to access the protected shell of any server quickly and quickly, in addition to accessing the SFTP service, which allows you to view all the server folders with administrator permissions (excellent for managing system files and folders without be physically present in front of the server).
To use the app, simply start it, indicate the access information to the server as previously seen and enter the password when requested; automatically the app will connect to the server and offer us the shell from which to issue commands, with the possibility of saving credentials for future access.
Alternatively, we can use the free JuiceSSH - SSH Client and JuiceSSH Performance Plugin apps on Android.

With these two apps we can both send commands on a secure shell and check the performance of our server, thanks to the connection plugin that will show in real time the consumption by CPU, RAM, network, disk and the average load (very useful if we have a site with many visits or servers with few capacities).

Conclusions

Managing an SSH server and sending commands on a secure shell are certainly operations by industry experts and system administrators, but if we want to check every aspect of our server for the website we are managing, SSH is definitely one of the tools you need to learn to use immediately.
If you want to learn new commands from prompts or for PowerShell, please read our Guide to Command Prompt Cheats (CMD). If instead we want to connect to an FTP server, we can find all the necessary information in our guide on How to connect to an FTP server from PC and smartphone.
To create a new data server to be used as a personal and secure cloud, we can read our in-depth analysis on how to create a personal and free Cloud Server on your PC.

Leave Your Comment

Please enter your comment!
Please enter your name here