I am in fact and I am tired of using configuration files This kind of thing, sometimes see large and complex configuration files, and even complex code, always feel that the design of the configuration file of the people are putting the cart before the horse.
But ssh this configuration file is really very simple and easy to use, let me experience a little bit of the pleasure of the configuration file.
I probably set up and manage my SSH connection before using SSH confg.
The first line in a centralized place, such as I create a folder on the Desktop SA, and then in this folder put on their own frequently connected Server connection command made a script similar name called
Ssh-redis
#!/bin/shssh [email protected]115.28. 39.64 A
Make a shell script that puts the address you want to ssh into. The SA folder is then set to the environment variable so that it can be called from anywhere in the terminal.
Because I use the zsh myself, so in my. ZSHRC, set the path to this folder
Export path="/users/piperck/desktop/tools/sa: $PATH"
Then open a shell and you can enter Ssh-redis anywhere to easily log on to the target server.
In addition to the above approach, of course, you can also choose to use Alias in. zshrc or. BASHRC to specify an SSH login code as the name of the command to execute the command such as
" ssh www.xiachufang.com-p "
Actually, it's very handy. I think, but as a late-stage lazy cancer programmer every time the new server needs to be configured, it feels that this method of adding scripts is a huge hassle, and the folder inside the script will be more and more. Is there a more elegant way to do this?
The SSH config profile solves this problem and allows all scripts to be re-placed back into a file
Create a config file under ~/.ssh/and edit the configuration file in the following format:
Host Lab HostName Amazon.com User Piperck ~/. SSH/Id_rsa
Host: It's the name we used when we entered the command, like I'm a lab, so I need to use the SSH command.
SSH Lab
Note that this is a space, not just my script loses the middle of the Ssh-redis is a horizontal line, because the script can use their own name, it is a good thing.
HostName: is the host name of the target host, which is the name of the address that we use after SSH.
PORT: the specified port number.
User: the specified login username.
Identifyfile: The specified private key address.
Then you can use SSH lab to log in happily. In the same way, you can create countless similar configurations within this config file, and you don't have to write scripts every time. It seems to be quite handy.
Preference:
Http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/Simplify your life and an SSH config file
Use SSH config profile to manage SSH connections