Created
April 12, 2013 13:11
-
-
Save aont/5371891 to your computer and use it in GitHub Desktop.
シェルスクリプト上でのSSH接続の再利用 ・パスワード入力は最初だけ
・鍵を作ってない人でも使えるはず(ssh-agentの代わりになる)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| echo start ssh session 1>&2 | |
| ssh -T -N -f -oControlMaster=yes -oControlPath=~/.ssh/master.$$.%r@%h:%p hoge.com | |
| echo command execution on remote 1>&2 | |
| ssh -oControlMaster=no -oControlPath=~/.ssh/master.$$.%r@%h:%p hoge.com echo echo on remote | |
| echo close connection 1>&2 | |
| ssh -O exit -oControlMaster=no -oControlPath=~/.ssh/master.$$.%r@%h:%p hoge.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment