1. Install SSH

It is very easy, I strongly recommend you install it on Linux or WSL(Windows Subsystem for Linux), I will record how to install WSL at: How to install WSL . And I will give you my reasons Why Stop Coding on Windows.

Almost all Released Versions of Linux have already installed SSH, but if you find there is no SSH for you computer, just install it from apt.

1
sudo apt install openssh-server

Check status of ssh:

1
sudo systemctl status ssh

If you find result below, you are successful.

1
2
3
 ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2024-11-12 10:21:34 UTC; 1min 32s ago

you can restart ssh make sure it work.

1
sudo systemctl restart ssh

2. Config SSH

LATER To speak of, almost all Cloud Server Retails set Firewall to protect your safety, if port 22 is closed, you will never connect to your server, please make sure you open at lease port 22. I will introduce it: How to set Firewall.

There are two methods to verify your identification:

LATER Password: How to set SSH login password

SSH-key:How to set SSH key pair

LATER I will introduce Asymmetric Encryption at here.

After we generate a SSH key pair, we will find key pair file at:

1
2
~/.ssh/id_{encrypt_method}
~/.ssh/id_{encrypt_method}.pub

id_{encrypt_method} is your private key, please remember never leak this file to anyone.

id_{encrypt_method}.pub is your public key, you should upload it to your Cloud Server.

LATER Here is How to upload a file to Remote Server.

Besides, we can copy the content of id_{encrypt_method}.pub to ~/.ssh/authorized_keys directly, to speak of, this file can contain many public keys, every key just occupies one line.
For example:

1
2
3
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUcN+UpNbVOI9pHj796/Sd4+iHbAdBOQvSPq [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUcN+UpNbVOI9pHj796/Sd4+iHbAdBOQvSPq [email protected]
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICUcN+UpNbVOI9pHj796/Sd4+iHbAdBOQvSPq [email protected]

3. Connect Remote Server

LATER Next, we can connect our server through SSH key without password. This is very useful, for example, we can Control Remote Server to Execute Command through SSH Connection without Login.

Now, let’s test our connection:

1
ssh user@your-server-ip

image.png

Now, we have finished SSH Connection.

If there are any other question, I will add at here.