Skip to content

Instantly share code, notes, and snippets.

@thecodesmith
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save thecodesmith/d6863480f4d2f9b7071f to your computer and use it in GitHub Desktop.

Select an option

Save thecodesmith/d6863480f4d2f9b7071f to your computer and use it in GitHub Desktop.
Basic SSH config file and usage
# Notes:
# Port field not required, defaults to 22
# IdentityFile field not required, defaults to ~/.ssh/id_rsa
Host github
User git
HostName github.com
IdentityFile ~/.ssh/id_rsa
Host laptop
HostName 192.168.0.200
User thecodesmith
Port 22
IdentityFile ~/.ssh/id_rsa
# Port-forwarding example
Host tunnel
HostName database.example.com
IdentityFile ~/.ssh/thecodesmith.example.key
LocalForward 9906 127.0.0.1:3306
User thecodesmith
@thecodesmith
Copy link
Copy Markdown
Author

Usage from console:

With git:

git clone github:thecodesmith/repo

With ssh:

ssh laptop

Local port-forwarding:

ssh -f -N tunnel

Port-forwarding this way allows pointing to localhost:9906 which will forward to remote (example.com) port 3306. This example taken from http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment