Last active
October 4, 2017 04:13
-
-
Save david-sanabria/596974c85083f2a2d0722c496db8f6d9 to your computer and use it in GitHub Desktop.
Example SSH Config Entry for personal accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SSH_CONFIG example | |
# David Sanabria, 2017-01-24 | |
# | |
# This is an example of a personal SSH config file. You need to add this | |
# file to the ssh root directory on your computer, which is typically found in your | |
# home directory (e.g. ~/.ssh/config). You can learn more from the command line by | |
# typing "man ssh_config" from your terminal (*nix) or from my blog entry on this topic | |
# at http://bit.ly/2jX2GQr (Wordpress). | |
# | |
# You can safely delete every line in this example gist that starts with the "#" comment | |
# character. | |
# | |
# Using this approach allows you to connect to your target server using the following | |
# simple command (you can use SFTP this way too!): | |
# | |
# EASY! --> ssh dev-app-svr | |
# | |
# Rather than the harder way of of specifying everything on the command line | |
# | |
# HARD! --> ssh -i ~/.ssh/king-julian-development [email protected] | |
# | |
# The entry below will allow you to connect to your hypothetical application server in | |
# your development environment. This example assumes the following: | |
# 1. Your target server is 192.168.10.75 | |
# 2. Your username on the server is "king-julian" | |
# 3. You have created an SSH keypair specifically for use in your development server | |
# (always a good practice), and named the keypair "king-julian-development" (private) | |
# and king-kulian-development.pub (public key) | |
# 4. You have already added the public key to the ~/.ssh/authorized_keys file on the target server. | |
# Example Host Entry | |
Host dev-app-svr | |
# Target Server and port number | |
Hostname 192.168.10.75 | |
Port 22 | |
# Your Credentials | |
User king-julian | |
IdentityFile ~/.ssh/king-julian-development | |
# These commands make sure that your connection doesn't hang if you get | |
# disconnected, and also keep sending traffic so that your server doesn't | |
# think you're just an idle connection. | |
ServerAliveInterval 30 | |
ServerAliveCountMax 3 | |
TCPKeepAlive yes | |
# Bonus for reading this far! Here is a command that will easily list all of your config entries | |
# in case you forget them: | |
# | |
# grep ~/.ssh/config -e 'Host ' | awk '{print $2}' | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment