By creating a local configuration file for SSH, you can create shortcuts for servers you frequently access, in addition to configuring more advanced options. This article will demonstrate how to create a shortcut to your VPS server, including how to keep your connection active.
This article has the following dependencies:
- Please make sure you have a basic understanding of SSH and have configured access for the root user or a domain user. See Connecting via SSH to your server for assistance.
- example.com is used as an example. Please be sure to replace this text with the proper information for your site or server.
- This article assumes that you are using a Unix operating system, such as Mac OS X or Ubuntu. We will use OS X as our example. Please modify as needed for your environment.
READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
1. Launch the terminal application on your local computer and create your config file in your home directory:
On OS X, this is located at /Applications/Utilities/Terminal.app. Consider dragging this application into your Dock for convenience.
Your .ssh directory is automatically created when you use the ssh command for the first time. If you have never used ssh before under this user account please create the directory first using:
mkdir /Users/username/.ssh && chmod 700 /Users/username/.ssh
2. Edit the file using vi or any Unix text editor you are comfortable with. We will use vi:
3. There are many options for your config file. Below is an example entry for a shortcut to your VPS server:
Host VPS HostName example.com User domainuser
4. Now that you have your shortcut created, you can add even more options directly below these entries. For instance, maybe you want to make sure your session "stays alive" while you step away from your keyboard for a bit. The following example will refresh your connection every 30 seconds for a maximum of one hour:
ServerAliveInterval 30 ServerAliveCountMax 120
5. Perhaps you have both a Grid and a VPS service with us. Here is an example file showing multiple hosts:
Host VPS HostName vps.example.com User ftpuser ServerAliveInterval 30 ServerAliveCountMax 120 Host grid HostName grid.example.com User email@example.com ServerAliveInterval 30 ServerAliveCountMax 120
- Running the command "man ssh_config" in a Terminal will show you detailed usage information.
- http://www.openssh.com/manual.html OpenSSH homepage, including a section on ssh_config