Install and Config SSH Connection
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 | ● ssh.service - OpenBSD Secure Shell server |
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 | ~/.ssh/id_{encrypt_method} |
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 | 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 |
Now, we have finished SSH Connection.
If there are any other question, I will add at here.