Featured image of post Basics of SSH

Basics of SSH

Introduction to OpenSSH

Introduction

Secure Shell - de facto standard way to get access to a remote terminal on an virtual server. On the computer where you need to get access, SSH server is installed, and on the computer where the operator works, SSH client is installed. Through SSH we can:

  1. Transfer files
  2. Execute commands on the target server
  3. Get information about the target system and perform simple automation

On Linux and MacOS, we have a terminal - SSH, which is usually set up by default. For Windows, I used the following options:

  1. MobaXTerm - convenient, but paid. Suitable for non-commercial use, but you’ll need to buy a license if you want to use it in a company. Advantages:
    • Immediately provides a file manager with drag-n-drop files to the target system
    • Normal keyboard support and RSA key support
  2. Git - when setting up Git, it includes Git Bash and an SSH client. Very close to the usual Bash.

Connecting

1
ssh [-p <ssh порт>] <пользователь>@<ip целевого хоста>

The port is optional, defaulting to 22, but it’s highly recommended not to run the SSH server on the standard port, as the world is full of automated bots that scan networks and find virtual machines with SSH on the standard port and simple passwords, trying to add them to some botnet. I once fell for this, but it’s a different story…

Copying Files

To copy files to the target host, you can use scp.

1
scp [-P <ssh порт>] /path/to/local/file <пользователь>@<ip целевого хоста>:<путь на сервере назначения>

Note:

  1. The port for scp is specified using -P, whereas for ordinary SSH - -p.
  2. The folder on the target machine should belong to the user you’re connecting with, or you’ll need permission to write to that folder\file.
Licensed under Apache License, Version 2.0
Last updated on Oct 17, 2024 12:47 +0300
All rights reserved
Built with Hugo
Theme Stack designed by Jimmy