Skip to content

Instantly share code, notes, and snippets.

@oprearocks
Last active September 20, 2019 00:17
Show Gist options
  • Save oprearocks/fe17eff7843f8b3dcaca to your computer and use it in GitHub Desktop.
Save oprearocks/fe17eff7843f8b3dcaca to your computer and use it in GitHub Desktop.
An SSH workflow that's easier on your brain
# List all information about the config file, under the ssh/ directory
adrian@zen ~/D/blog> ls -al ~/.ssh/config
-rw-r--r-- 1 adrian staff 210 Mar 1 13:59 /Users/adrian/.ssh/config
# If you get "No such file or directory [...]", run the command below
adrian@zen ~/D/blog> touch ~/.ssh/config
# Check again, to see if the file has been properly created
adrian@zen ~/D/blog> ls -al ~/.ssh/config
-rw-r--r-- 1 adrian staff 0 Mar 1 17:12 /Users/adrian/.ssh/config
Host remote-machine # The shorter name you will use with the ssh command
HostName 192.168.33.10 # The machine's IP address or hostname
User adrian # Your username on the machine
IdentityFile ~/.ssh/remote_machine.key # If you don't want to type the password every time, get one of these
RemoteForward 5858 5858 # Port forwarding (for tunnelling) - I use it for NodeJS remote debug
ForwardAgent yes # Forward the ssh key to machines that you connect to from the remote machine
# This is my git server
Host git
HostName 192.168.33.10
User adrian
IdentityFile ~/.ssh/git_server.key
# I use this to connect to other machines on the same network
# hence, I'm forwarding my connection to the authentication agent
Host manager
HostName 192.168.38.1
User root
IdentityFile ~/.ssh/manager.key
ForwardAgent yes
# Forwarding port 5858 to localhost for remote debugging
Host nodejs
HostName 192.168.33.11
User adrian
IdentityFile ~/.ssh/nodejs.key
RemoteForward 5858 5858
Host db
HostName 192.168.33.12
User root
IdentityFile ~/.ssh/db.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment