Connection configuration
Take creating a new quick connection called gzlaoben.
- in
/etc/ssh/ssh_config.d
Create a subconfiguration file under the directorygzlaoben.conf
.- When creating child profiles, check the master profile
/etc/ssh/ssh_config
Whether the file containsInclude /etc/ssh/ssh_config.d/*.conf
.
- When creating child profiles, check the master profile
- in
gzlaoben.conf
Add the following configuration items to the file
Host gzlaoben # Host A shortcut used to configure SSH connections
Hostname gzlaoben.xyz # Hostname Specifies the host address for SSH connections
User root # User Specifies the User name used to connect to the host
Port 22 # Port Specifies the Port used for SSH connections
IdentityFile ~/gzlaoben_key # IdentityFile Specifies the path for storing private files used for SSH connections
ServerAliveInterval Specifies a number of seconds for the client to send heartbeat packets to the server every specified number of seconds to maintain the connection.
ServerAliveInterval 30
# ServerAliveCountMax Specifies the number of times a client sends heartbeat packets to the server and disconnects without responding.
ServerAliveCountMax 100
Copy the code
- Use the following command to connect to host gzlaoben.xyz as user root
ssh gzlaoben The parameter of the SSH command is the Host specified in the configuration file.
Copy the code
Recording Connection Logs
You can use the tee command to write output from an SSH connection to the file specified by tee. Take the gzlaoben connection log as an example:
You can use variables in file names, such as log variables
ssh gzlaoben | tee ~/ssh_log/$(date +%Y%m%d_%H%M%S).log
Copy the code