Pages

Categories

Archives

[Google]

Sponsored Links

ssh menu

I wrote this script to help search my known hosts file for the environment I needed to connect to since all hosts had same name but different sub-domains depending on environment. I could make it more flexible but I really only wrote it for me…maybe I will swing back to it.

#!/bin/bash

USER=”root”

OPTIONS=”connect scp command”

 

case “$1” in

‘connect’)

case “$2” in

‘dev’)

for i in `grep ‘\.dev.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

echo -n $i; echo -en \\033[60G ;ssh $USER@$i

done

;;

‘test6’)

for i in `grep ‘\-6.test.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

echo -n $i; echo -en \\033[60G ;ssh $USER@$i

done

;;

‘test8’)

        for i in `grep ‘\-8.test.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

                echo -n $i; echo -en \\033[60G ;ssh $USER@$i

        done

;;

‘stage’)

        for i in `grep ‘\.stage.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

                echo -n $i; echo -en \\033[60G ;ssh $USER@$i

        done

;;

‘prod’)

        for i in `grep ‘\.prod.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

                echo -n $i; echo -en \\033[60G ;ssh $USER@$i

        done

;;

esac

;;

        ‘list’)

                case “$2” in

                ‘dev’)

                        for i in `grep ‘\.dev.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

echo $i

                        done

                ;;

                 ‘test6’)

                        for i in `grep ‘\-6.test.domain.com’ ~/.ssh/known_hosts | awk -F, ‘{print $1}’ | sort | awk ‘{print $1}’`; do

                                echo $i

                        done

                ;;

                 ‘test8’)

Comments are closed.