How to use ssh? As well as installation and configuration (Linux, Windows, macOS, Android, iOS)

  1. Installing SSH in Linux OS
  2. SSH connection (with password)
  3. Creating an SSH-key and connecting without a password!
  4. How to create an SSH key?
  5. How to add SSH-key to the server?
  6. SSH Windows Client
  7. Connecting via SSH with a password in Windows
  8. Connecting via SSH key in Windows
  9. Create a key
  10. Key transfer
  11. Mac SSH Client
  12. SSH client android and iOS
  13. Transfer and download files over SSH (SCP)
  14. For windows
  15. SSH setup
  16. SSH port change
  17. Login only via SSH key:

This article will tell you how to install SSH in Linux, Windows and Mac, how to configure and how to use! Every detail! It will be interesting!

SSH is a popular protocol for remote control (administration) of operating systems on the Linux, Unix kernel. For Linux newbies, it’s not at all clear how to install this protocol, configure it and use it, so I decided to fix this article!

One of the most popular operating systems running on the Linux kernel is Ubuntu, so we’ll explain about ssh on it.

First, we will explain all the actions with a Linux example, and then on Mac and Windows!

Installing SSH in Linux OS

In 99.99% of cases, a Linux ssh client is already installed on Linux, with which you can connect to a remote machine. But if you want to connect to the computer you are currently on or on any other, you need to “download ssh server”.

It is very simple to do this, everything you need is already in the repositories (a la program store), open a terminal and enter the command:

sudo apt install openssh-server

That is, a server part is needed that makes the computer available on the network using the ssh protocol. There is a client part that is already installed on your computer, and using it, you connect to a remote computer.

SSH connection (with password)

Open a terminal and enter the command to connect to the remote machine:

ssh UserName @ IP Address

First, we write ssh, then the username that is on the remote machine, then the @ (dog) sign and the IP address. For example:

ssh sasha @ 100.08.30.48

As a rule, ssh connection occurs on port 22, if you forcibly changed it, you need to specify it. To do this, at the end write -p number. Here is an example:

ssh sasha @ 100.08.30.48 -p 3040

After you have connected and if this was the first connection to the machine, you will need to add the machine to the trusted ones - type yes and press Enter. This is done once. After you have connected and if this was the first connection to the machine, you will need to add the machine to the trusted ones - type yes and press Enter

Next, you need to write a user password. It will need to be specified every time!

Creating an SSH-key and connecting without a password!

In order not to remember the password and not to enter it every time, especially if you have many Linux servers, you can create a special SSH key. This key will allow you to connect from an already “known” machine with a “known” server, without using a password.

How to create an SSH key?

On the computer for which you are now creating a key, and then, it will need to be copied to our server!

Create a key for the current computer:

ssh-keygen -t rsa

Then the question will be asked where to save the key, by default this is your home directory, hidden folder ./ssh . In most cases, you can just press Enter to skip.

Next you will be prompted to create a code word, also press Enter to skip!

The key is created, now you need to add it to a remote machine or server.

How to add SSH-key to the server?

To do this, enter the command:

ssh-copy-id Username @ IP address

We write the ssh-copy-id command, then the username that exists on the remote machine, the @ (dog) symbol and the IP address. For example:

ssh-copy-id sasha @ 100.08.30.48

Next, we specify the password of the user who is on the remote machine or server, after which the key will be copied.

Now you have the opportunity to connect to a server or another machine without using a key, simply by entering a username and password!

SSH Windows Client

One of the most popular programs for working with Linux servers over SSH in Windows is Putty. You can download this SSH Windows client at this address - putty.org .

Connecting via SSH with a password in Windows

Connecting to Putty via SSH is very simple! Enter the IP address, if you changed the port, then specify another port and click Open: Connecting to Putty via SSH is very simple and after connecting the username and password!

Connecting via SSH key in Windows

If you don’t want to enter a password every time and use the ssh key in Putty, then, like in Linux, you must first create a key and then transfer it to the server.

Create a key

  1. Download another program Puttygen and run it
  2. Click the "Generate" button and enter the mouse on the sides in order to create a key
  3. After creating the key, click "Save Privat Key" and specify the save location, save with the extension .ppk
  4. Copy the entire key to the clipboard from the very first ssh-rsa line:

We do not close the program yet and run Putty to connect

Key transfer

  1. We save our Linux server in sessions as follows:
  2. Connect to server
  3. Go to the directory ./ssh: cd ~ / .ssh /
  4. Next, using nano editor open the authorized_keys document to edit the nano authorized_keys

    and add the previously generated key to this file and save the data and add the previously generated key to this file and save the data

  5. Close putty ssh
  6. Open Putty, click "Load"
  7. Further in the SSH settings -> Auth, specify the path to the key file.ppk
  8. Click Open, then the session will start on the server without using the key!

Mac SSH Client

Since macOS is based on UNIX system, you can connect via ssh directly from the terminal!

If you want to not use a password, you must first install Homebrew:

/ usr / bin / ruby ​​-e "$ (curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

and then everything is as in Linux.

There is also a convenient mac ssh client - Termius .

SSH client android and iOS

The most convenient SSH client for iOS and Android is the Termius app!

For Android:

For iOS:

Transfer and download files over SSH (SCP)

To upload a file from the local machine to the server via ssh on Linux and macOS:

scp file1.tar root @ ip_adress: / home / dir

Copying a file from a server to a local Linux or macOS computer:

scp userName @ ip_adress: /home/file1.tar / var / www /

From server to server:

scp user @ server_ip1: /home/file.txt user @ server_ip2: / home /

For windows

To move files over SSH in Windows is used pscp .

pscp.exe file.zip root @ ip_server: / var / www /

SSH setup

If you need to add an entry to SSH immediately by root:

SSH port change

Since, by default, ssh is configured on port 22, it is not safe to use the server. Therefore it is worth changing the port!

Using nano, edit the sshd_config document, enter the command:

sudo nano / etc / ssh / sshd_config

and change the Port values ​​to the required ones:

# What ports, IPs and protocols we listen for Port 22

Login only via SSH key:

Using nano, edit the sshd_config document, enter the command:

sudo nano / etc / ssh / sshd_config

Change the PasswordAuthentication values ​​from yes to no:

RSAAuthentication yes PubkeyAuthentication yes PasswordAuthentication no

Do you still have questions? Write them in the comments, tell us what you got, or vice versa!

That's all! Read more useful articles and instructions in the section. Articles and Linux Hacks . Stay with the site Android +1 , then it will be even more interesting!

How to create an SSH key?
How to add SSH-key to the server?
How to create an SSH key?
How to add SSH-key to the server?