Thursday, October 3, 2013

ssh hopscotch

hot damn my job is fun.
me on system1 is pubkeyed on system2, but not system3.
toor on system2 is pubkeyed on system3.
me needs to run something on system3
ssh magic!

me@system1:~$ ssh toor@system2 "ssh notme@system3 \"ls -la ~\""
and here's a real world example of the excitement from a correspondent we shall call dr. excitement...
scp %1* 10.100.100.117:~/
ssh 10.100.100.117 "ssh 192.168.1.132 \"sudo service tomcat7 stop;sudo rm -v /var/lib/tomcat7/webapps/somethingneat.war\""
ssh 10.100.100.117 "scp %1.war 192.168.1.132:~/"
ssh 10.100.100.117 "ssh 192.168.1.132 \"sudo cp -v ~/%1.war /var/lib/tomcat7/webapps/somethingneat.war; sudo chown -v tomcat7 /var/lib/tomcat7/webapps/somethingneat.war; sudo service tomcat7 start\""
echo woo\!

No comments: