Update cookies preferences

SSH and its basic command

Programmers, system administrators, devops developers and testers often find common ground by using the same technologies. For example, the ability to remotely access a server can be useful for each of the above-mentioned professionals. Let's consider the basic principles of working with SSH protocol on a simple level (without unnecessary details and complicated terms).

How SSH works

SSH (Secure SHell) is a means of securely accessing various systems (Linux, Windows, Mac) over a network. It was created to replace the unencrypted Telnet. It protects the information being transmitted using encryption and usually runs on port 22. SSH allows you to remotely manage user data on a server, perform service tasks and work with databases through a console interface.

What connection verification methods SSH uses

  • By the client's IP address, but this is not the most secure method because of the possibility of address spoofing.
  • By client's public key and user name. For this purpose it is necessary to create a private (private) and public (public) key. Using one key to encrypt information, it can only be decrypted with another key.
  • By the client's password, which is transmitted in encrypted form. This method is one of the most common, but requires a password to be entered each time a connection is made.
To access the SSH protocol (login to the server console) from the Windows operating system, you need to install special software (SSH client), such as the free PuTTY

SSH server and SSH client

Two basic elements are needed to establish an SSH connection: an SSH server and an SSH client. The server listens on a specific port (standard is 22) and grants access to the user after successful authentication. All commands sent through a secure channel to the SSH server from the SSH client via a terminal are executed on the server and the result is sent back to the client.

Selecting from several options

An SSH client is used to access a remote web server and execute various commands. SSH clients are available for all operating systems. There are both paid and free variants.
  • For Linux/BSD it is recommended to use openssh-client, putty, ssh, Vinagre.
  • For Windows users, such programs as PuTTY, SecureCRT, ShellGuard are suitable. The Windows SSH client based on OpenSSH is already installed in Windows operating systems since version 10 1809.
  • On Android mobile devices, you can use the connectBot application.

SSH commands - what they are in simple words

SSH access is usually used when it is necessary to rent a dedicated server or specialized hosting for websites, mostly on VIP-tariff, as well as when renting a virtual server.
Let's imagine that you live in New York, and a client from Chicago has a "broken" online store, which is located on his server. What to do in such a situation?
There are several options.
  • Fly to another city and solve the problem on the spot, but it takes a lot of time and effort.
  • Connect to the server remotely via SSH, fix errors via the command line without getting up from a comfortable chair in a New York business center.
SSH works over a secure network protocol to send commands and data. When you communicate with a remote server or computer via SSH, it's like you connect your keyboard to it. You can run programs, perform actions through command line remotely from the comfort of your home.

What commands can be executed over SSH

  • Configuration of server equipment.
  • Programming.
  • Installation of various CMS: WordPress, Bitrix, OpenCart.
  • Finding and eliminating errors on the site.
  • Starting and stopping programs.
  • Copying, pasting and moving files.
  • Configuring security settings.
  • Rebooting the server.
  • Deleting files.
  • Formatting a hard disk.
  • Remote software startup and file opening.
This list does not exhaust all the features of the SSH command list, but it allows you to understand a wide range of nuances of working with the server remotely.

Some basic commands

  • The command to display the contents of a directory is
    lsOutputs a list of files and directories on the server. You can use additional options to get more information:
    ldisplays information about files: size, creation date, owner, and permissions;
    aallows you to view hidden files on the server and VPS.
  • The command to create a directory is
    mkdirTo create a new directory, use the
    mkdir  command, specifying the folder name in lower case. After creating, run
    ls  to verify that the new directory was successfully created.
  • The command to change the directory is
    cdJust type
    cd  and the directory name, then press Enter. To go back, use
    cd ..
  • The create file command is
    touchCreates a new file in the selected directory. Navigate to the desired directory with
    cdthen type
    touch  and the file name.
  • The copy file command -
    cpSpecify the name of the original file and the new file.
  • The delete file command is
    rmDeletes the selected file or directory.
  • The display current position command -
    pwdDisplays your current position in the file system.
This list doesn't exhaust all the features of the SSH command list, but it allows you to understand a wide range of nuances of working with the server remotely.

Other useful commands

find  - search for a file,
php --version  - view PHP version on the server,
w  - view active users on the server at the moment,
df  - display information about disks, partitioning and free space,
tar  - extracts files from archive.tar to the current directory or, on the contrary, archives them.

Basic information management commands

  • clear  - a great command for clearing the terminal session of previous output, which helps to better focus on the current operation.
  • history  - view the history of used commands. You can use it to recall commands repeatedly or to quickly find previous actions.
  • whatis  - an indispensable command for getting brief information about any installed application. Just type
    whatis  and the name of the application.
  • man  + package name is a great way to get detailed documentation about a particular installed application. This allows you to quickly find information about the application's features, how to use it, and possible problems.

Efficient SSH protocol management

To conveniently connect to a remote PC via SSH, two important options are recommended.
  • ssh -pwhich allows you to replace the default port 22 with another port. This increases security and protection against automated hacker attacks by bots.
  • ssh-copy-id -iwhich copies the key to the server, making it possible to log in without having to enter a username and password, but using only the key.
Use symbols - text explanations that can be very helpful.
  • ;  - used as a delimiter to execute several commands in a row.
  • &&  - similar to, but with an important difference. Commands combined with && will be executed one by one only if the previous command was successful.
  • |  - allows you to run two commands simultaneously. This is useful when you want to extract information from an application and then find certain data in the resulting output.
  • ~  - abbreviation for /home/account name/. Often found in instructions.


Using SSH commands you can remotely manage files, configure network functions, server settings and much more. SSH connection is characterized by an intuitive and simple interface, as well as a high level of security when transferring any data.
23 Apr 2024, 16:42:44