Skip to content

Instantly share code, notes, and snippets.

@charlestang
Last active October 12, 2015 17:17
Show Gist options
  • Save charlestang/4060351 to your computer and use it in GitHub Desktop.
Save charlestang/4060351 to your computer and use it in GitHub Desktop.
Interactively selecting server to connect from config file
#!/bin/bash
server_config=~/.ssh/server_config
echo 'Servers:'
cat -n $server_config
echo 'Please seletct: >'
read n
echo 'Connecting....'
command=`sed -n ${n}p $server_config | awk -F'#' '{ print $1; }'`
$command
@charlestang
Copy link
Author

server_config 文件的格式如下

ssh root@192.168.1.101      #virtual
ssh root@192.168.1.123      #testing

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