SSH is a reliable protocol designed for remote logon sessions and other network services. The SSH protocol can effectively prevent information leakage during Remote Management. S h was initially a program on the u n I X system, and then quickly expanded to other operating platforms. S h can make up for vulnerabilities in the network when used correctly. Clients include ssh programs and other applications such as scp remote copy), slogin remote login), and sftp secure file transfer. SSH has many cool features. How can it be your daily work partner? I think you need to know the following 16 tips for using SSH efficiently, they help you save much more time than you need to configure them.
1. jump between servers
In some cases, you may not be able to directly connect to a server, but you need to use an intermediate server for transit. This process can also be automated. First, make sure that you have configured public key access for the server and enabled agent forwarding. Now you can use two commands to connect to the target server without any prompt:
$ Ssh gateway
Gateway $ ssh db
Then add the following configuration in your local SSH Configuration:
Host db
HostName db.internal.example.com
ProxyCommand ssh gateway netcat-q 600% h % p
Now you can use a command to directly connect to the target server:
$ Ssh db
Here you may need to wait for a long time, because SSH requires two authentication. Note that netcat may also be written as nc or ncat, or g must be added before, you need to check your intermediate server to determine the actual parameters.
2. Save the user name
If your user name on the remote server is different from your local user name, you can also set it in SSH Configuration:
Host www * mail
HostName % h.example.com
User simon
Now, even if my local user name is smylers, I can still connect to my server like this:
$ Ssh www2
SSH will use the simon account to connect to your server. Similarly, Putty can save this information in your session.
3. Host alias
You can also define the host alias in your SSH configuration, as shown below:
Host dev
HostName dev.internal.example.com
You can also use wildcards for grouping:
Host dev intranet backup
HostName % h.internal.example.com
Host www * mail
HostName % h.example.com
In Putty, you can save a separate session for each host name, and double-click to establish a connection (but it may not support wildcards ).
4. Omit the Host Name
It is boring to enter the complete host name of the server to create a new SSH connection, especially when you have a group of servers with the same domain name but different sub-domain names that need to be managed, for example:
* Www1.example.com
* Www2.example.com
* Mail.example.com
* Intranet.internal.example.com
* Backup.internal.example.com
* Dev.internal.example.com
You may have configured your network to directly use short domain names, such as intranet. However, if your network does not support it, you can solve the problem by yourself instead of asking the network administrator for help.
The solution varies slightly depending on the operating system you use. The following is the configuration of my Ubuntu system:
Prepend domain-search "internal.example.com", "example.com ";
Then you need to restart the network: $ sudo restart network-manager
These two commands may be slightly different for different systems.