CityHost.UA
Help and support

What is SSH and the main ways to work with it: Web SSH, Midnight Commander, PuTTy, terminal

 7356
16.02.2022
article

When renting virtual hosting, VDS or a dedicated server , the client does not come to the data center to administer them - it would be too difficult and inconvenient. Thanks to the remote connection protocol, he can sit at home at his laptop and manage his hosting. It is difficult to imagine what the Internet would be like without SSH technology: webmasters would not create websites, businesses would not rent servers, and online stores would not become as popular as they are now.

This article is dedicated to the topic of SSH connection and useful tools for working with it. You will learn how to independently connect to the hosting and server from different operating systems, and at the end we will share with you useful SSH commands.

What is SSH and how to use it

SSH is a secure connection script for remote server management. If you've ever rented hosting or VDS, you've probably used the control panel in a customer account. She could look, for example, like this.

This is a graphical shell that makes it easier to work with the server. All programs have such visual panels, including operating systems. We manage our hosting or VPS by clicking buttons with the mouse, but protocols are working under the surface of the user-friendly interface.

Read also: Overview of control panels on VPS .

SSH is a non-graphical shell, the deepest level of human-machine communication. Such interaction can be carried out directly, using a console or terminal. They look like a black screen where text commands should be entered.

The term is translated as Secure Shell. This technology was invented to replace the ancient TELNET protocol. It also allowed remote control of computers, but all data was transmitted in the open (even logins and passwords). That is why they invented a safe method that not only encrypts all data, but also checks the integrity of the information.

But a question arises. The hosting has a file manager, FTP and other tools. Why would a normal client use SSH, learn all these commands, when there are simpler ways?

There are several reasons for this:

1. Some customers find it more convenient to administer the server via SSH. Such management is not much more complicated than working with graphic panels, and for those who have learned it before, there is no point in relearning. Moreover, all providers have different interfaces, and SSH is the same everywhere.

2. Some commands run only through this protocol. No matter how rich the toolkit in the account is, it does not cover all possibilities. Specific or rarely used commands can only be entered using SSH.

3. SSH data transfer protocol is necessary when working with some CMS, such as Drupal . The system is arranged in such a way that part of the commands can be entered only through SSH and in no other way.

Read also: TOP-3 CMS for creating an online store .

Working directly with SSH is an option for advanced customers and administrators, which opens up wider possibilities of interaction with the server. Knowing at least the basic principles of this technology, you will better understand the entire process of managing your hosting.

How does Web SSH differ from regular SSH?

SSH connection is a method, not a tool. Certain programs are required to connect using the server.

But the connection process itself is quite complicated for a beginner. I didn't enter the name of the server there, I didn't add the IP address to the allowed list, I seem to have logged in, but the password field is not visible.

To help users connect easily, we have installed Web SSH in the Cityhost virtual hosting control panel.

With a browser and installed server-side utilities, you can connect via SSH with just one button.

What is VNC and Web VNC

When you open the control panel of your virtual server , you will see that there is no Web SSH option, but there is VNC and Web VNC. What it is?

Web VNC is also a system (protocol) for remote access. One of its features is that the computer/server from which management is carried out can be on a different operating system. The protocol bypasses SSH, and it is convenient to use in emergency cases - for example, if the client accidentally blocked the port or forgot the password from the server.

But VNC is not intended for permanent work, it is more of an additional tool.

How to connect via SSH to a hosting or server

We have understood the theory a little, and now let's move on to practice and try to connect via SSH to different types of hosting and from different operating systems.

Connecting to virtual hosting

First you need to enable SSH as it is disabled by default. Go to the "Hosting 2.0" section, click on the "Management" button opposite the hosting name and go to the SSH section.

Here you will also find the "Manage" button, after clicking which the system will ask you to set a password for SSH access. It can be invented or generated automatically. After that, SSH access should open within 15 minutes.

As soon as this happens, an additional option "Web SSH: Open" will appear. Click on it. You don't need to do anything else - a terminal for remote control has already opened in front of you and you can enter commands.

It is important to remember that you can only connect to virtual hosting via Web SSH. If you have a server, you will need other methods.

Connection to VDS and dedicated server

If the client PC has Linux or Mac OS installed, everything is very simple - they have built-in terminals. With Windows, everything is a little more complicated, you will need to install special utilities (although Windows 10 already has a built-in SSH client).

First, let's test the SSH connection to the server using the terminal.

In Linux, it is opened with the keyboard shortcut Ctrl+Alt+T. For Mac OS, you need to type Command + Space on the keyboard and type the word "Terminal" into the line - the search engine displays this tool at the top of the list.

After opening the terminal, you need to enter the command ssh login@servername, where you enter the login from the server received from the provider by e-mail, and servername is the IP address of the server (it is in the main information on the client panel).

The system will then request a password from the server, and only after that the client will be able to manage SSH.

So, for example, the process of connecting to a server under Linux Ubuntu looks like.

The most common utility for connecting SSH from under Windows is called PuTTY .

If you have Windows 10, the SSH client is already built-in. It is not always on, so sometimes you need to connect it. To do this, you need to activate "Developer mode" in the "Update and security" section, and then find "Manage additional components" (you can just kill in the search). There is an "Add Component" section where the "OpenSSH Client" connects.

We've covered the basic steps you'll need to take to connect to your server using a secure protocol. Depending on the computer, server or provider rules, there may be differences in the connection. But in any situation, you can consult the technical support staff, they are always happy to help.

Well, you're connected. What's next? We'll cover a few SSH connection features that you can learn to use, even if you're a novice administrator.

Basic SSH commands

ls — Show directory contents (list of filenames)

cd — Change directory

mkdir — Create a new folder (directory)

touch — Create a new file

rm — Delete a file

cat — Show the contents of a file

pwd — Show current directory (full path to this directory)

cp — Copy file/folder

mv — Move file/folder

grep — Search for a specific phrase in a file

find — Search for files and folders

vi/nano — Text editors

history — Show the last 50 used commands

kill — Terminates one process (specified by PID code)

killall - Differs from kill in that it can "kill" a program without even knowing its PID. All killall needs is the utility_name

rsync — Synchronizes files between two or more hosts

wget — Downloads a file from a given link

zip — Archives one or more files into a single .zip file

unzip — Unzips the archive

df -h — Displays the amount of free space on the hard disk

Midnight Commander

The console has Midnight Commander file manager installed. It is easy to operate and can perform many operations.

You can run it using the command:

mc

Features of Midnight Commander

  • Work with various archives and images of file systems as if they were ordinary directories.

  • Work with network file systems Samba, FTP, SFTP.

  • Performs file copying and moving operations in the background.

  • Built-in text editor with syntax highlighting.

  • Text mode based on the ncurses and S-Lang libraries. This allows the program to work both in the console and in various terminal emulators, as well as through remote connections, for example, the SSH protocol. Supports mouse.

  • Multilingual interface support.

  • UTF-8 encoding support.

Midnight Commander includes a text editor that can be run both internally and separately from the command line.

Server load monitoring

The htop command will help monitor the load. This is a program designed to display a list of running processes and information about them (process monitor) on the terminal. Created as an alternative to the top program.

It is started by writing the command:

htop

What you can do with htop

  • find out the time that has passed since the start of the OS;

  • monitor OS load (load average);

  • see the sizes of the memory pages located in the RAM ("Mem");

  • see the size of memory pages saved in a file or swap partition ("Swp");

  • view the load of all processors ("CPU") or each processor/core separately;

  • perform a search by pid (number keys) or by process name;

  • view files opened by the process;

  • monitor process system calls (similar to the functionality of the strace utility);

  • monitor calls by the process of library functions (similar to the functionality of the ltrace utility);

  • view processes launched on behalf of the user;

  • can output processes in the form of a tree (similar to the functionality of the pstree utility);

  • can show user process threads and kernel threads;

  • and more.

Learn more about HTOP .

Database import and export

You can move the database using console commands.

Import database:

mysql -h server name -u database_user -p database_name < database_dump_file

mysql --host="DB_SERVER" --user="LOGIN" --password="PASSWORD" "DB_NAME" < "DUMP_FILE.sql"

Export (backup creation):

mysqldump -h servername -u db_user -p db_name > filename

mysqldump --host="DB_SERVER" --user="LOGIN" --password="PASSWORD" "DB_NAME" > "DUMP_FILE.sql"

In the first case, the content of the specified file (in SQL format) will be loaded into the database, in the second case, the content of the specified database will be copied to the file.

***

SSH has been around since 1995 and has only improved over its nearly thirty-year history, demonstrating its reliability. Knowing how to use it is not necessary for a webmaster, but understanding how the SSH protocol works opens up many additional possibilities.


Like the article? Tell your friends about it: