If you have a high-performance personal PC, most tasks can be solved locally. However, it is more common for you to buy a small server or have a special server platform and then visit it locally. Today, this article, Micronet, collates several tips on connecting to remote Linux system servers. Friends can learn about it.
Save common SSH hosts to avoid repeated input
Access under Linux remote server The basic method of is SSH (secure shell). SSH is actually a network protocol used for encrypted login between computers to ensure that the original information cannot be parsed even if it is intercepted during transmission. SSH can be used as a protocol in many ways. OpenSSH in Linux, and push or Xshell in Windows. But only ssh in Linux is discussed here. When accessing a remote host in Linux, everyone must be familiar with the following instructions:
[email protected]
Where, - p specifies the port number, which is generally 22 by default. Unless otherwise specified for remote servers, - p22 can be omitted, followed by the user @ IP address. During the first access, you will be asked whether you want to add the public key of the host to the trust list. Of course, you will choose Yes.
The first tip: use sshconfig to add common servers
The question is, can we discuss not entering 'xuzhoggn @ 10 10 . 87 . 36’? Of course there are ways. You only need to create~/. Ssh/config file and add host information
#Using the vi editor
#vi~/。 Ssh/Configuration
Hostxzg
Hostname 10.10.87.36
Userxuzhougegn
Port22
Then you can use sshxzg to access the remote host. You need to enter all the information, which is very tiring and error prone.
Fast login without password verification
The second tip: use the ssh public key to avoid repeated password entry
The above technology allows you to access without entering the full name of the host, but still need to enter a password. If the password is long, people are prone to make mistakes. When Linux enters the password, it can't see anything, nor can it know how many characters are lost. If your computer is for your own use only, you can save the steps of entering a password.
The way to avoid every password authentication is to use the SSH public key. When you store the SSH public key of your PC on a remote server, the remote server trusts you completely and there is no barrier between the two people.
First, use ssh keygen to create a key (when the password is empty, you do not need to enter a password when logging in later)
$ssh-keygen-b2048
Generate public/private key pairs.
Please enter file inhibitosaveekey (/home/xzg/). ssh/id_rsa):
/home/xzg/。 ssh/id_rsaalreadyexists。
Empty for no phrase:
Enter the same password again:
your identificati on hasbeen savedin/home/xzg/。 ssh/id_rsa。
your publickey hasbeensavedin/home/xzg/。 ssh/id_rsa.pub。
Keyboard fingerprint:
sha 256:/1 dusqi 7 wrufsf 9 pg 3c jcstizghpdpyrco zVF/efVMxzg @ DESKTOP-CNF 0i 9c
The srandomortimageis of this key:
- [RSA2048] -
|.|
|o.|
|.|
|. o
|oS。==.| Oe
|=.o.o.*oX|
| .= oOO|
|.o=.o.B|
|. Out of Office/Masked Knight o
- [SHA256] -
Then add your ssh public key to~/. Ssh/authorized _ key has many methods in remote server
The task is suspended, and the terminal is safely shut down
In remote operation, once the terminal is closed, all processes running on the terminal will receive the SIGHUP signal, and then these programs will exit immediately. If your command needs to run for several hours or days, you certainly do not want to keep the terminal open because the network problem has not been solved.
Third tip: use screen/nohup to run programs for a long time
There are several solutions. Let's talk about nohup and screen here
The original name of Nohup is Do Not Hup, which means you can capture the SIGHUP signal sent by the terminal and ignore it, so you don't have to worry about your command being closed by the terminal.
If you don't know how long your command has been executed, so you don't know whether you want to enter nohup. In fact, it is better to use screen (or tmux)
Finally, in the above article, the Micronet sidebar introduced three tips for connecting to remote Linux system servers, namely, using sshconfig to add common servers, using ssh public key to avoid repeated password input, and using screen/nohup to run programs for a long time. Wait a minute, hope to help friends in need.
Micronet, Changzhou has 12 years of rich experience/cloud computing service provider, IDC operation experts in the field of IDC server leasing/hosting, and became the designated service center of Jiangsu Huawei Cloud in 2018. Changzhou Micronics Network is a professional service provider of Changzhou International Data Center, providing real 7 * 24 technical support and computer room technology. Telecom, China Unicom (Netcom |), double line and BGP multi line computer rooms are all over the country, providing you with the best layout scheme with the highest cost performance ratio!