Archive for February 16, 2012
SSH Configuration Files
Feb 16th
Lately I have been managing a ton of servers, all using different users, passwords, key’s etc. I wanted an easier way to access them, and a friend pointed out SSH config files. I personally hadn’t used them and there was not really some place to show there use other then great walls of text. I figured I would setup a post to keep track of how I been using them for both myself and anyone else that might be interested.
The config file is contained in your .ssh folder located in your home. There are a few directives in the files that I use constantly. Here is an example of a file that I might have setup
Host local-server-name HostName 0.0.0.0 Port 22 User Me IdentityFile ~/.ssh/local-server-name-key
The first value Host is what I want to use as a name for that server locally. Depending on how much typing you like to do you can make it as long or as short as you want. HostName is the ip or address used for connecting to the server normally. The Port only needs to be added if your using a port other then 22. User is the user name that you wish to connect to with. IdentityFile is the location of the private key that you might have setup on that server for authentication.
Once this file has been created and you have all your servers added, you can now access any of these servers via there name in most commands.
Connecting to the server via SSH
ssh local-server-name
Sending a file to the server
scp ./filename.text local-server-name:/
Your configuration file can have as many entries as you want for as many servers as you want. You can even have the same server setup multiple times with different User or User/IdentityFile. I hope this was helpful, I know it has saved me a ton of typing on many occasions.
