Skip to content

Instantly share code, notes, and snippets.

@legendtang
Created October 26, 2012 06:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save legendtang/3957248 to your computer and use it in GitHub Desktop.
Save legendtang/3957248 to your computer and use it in GitHub Desktop.
SSH with hosts
#!/bin/bash
read -p "Get your f**king hostname here:" hostname
read -p "Get your f**king username here:" user
ip=$(grep '[0-9]' orderless_hosts.txt | grep "$hostname" | sed 's/[a-z]..*[a-z]//' | sed 's/ //' | sed 's/;//' | cut -d : -f 1)
port=$(grep '[0-9]' orderless_hosts.txt | grep "$hostname" | sed 's/[a-z]..*[a-z]//' | sed 's/ //' | sed 's/;//' | cut -d : -f 2)
if [ $port='127.0.0.1' ]
then
ssh $user@$ip
else
ssh -D $port $user@$ip
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment