답변:
로부터 수동 :
-O ctl_cmd
활성 연결 멀티플렉싱 마스터 프로세스를 제어합니다. 때-O옵션이 지정되면,ctl_cmd인수는 해석 마스터 프로세스로 전달됩니다. 유효한 명령은check(마스터 프로세스가 실행 중인지 확인),forward(명령 실행없이 전달 요청 ), (전달을cancel취소),exit(마스터를 종료하도록 요청) 및stop(다중 멀티플렉싱 요청 수신을 중지하도록 마스터 요청)입니다.
이전 버전에는 check및 만 exit있지만 목적에 충분합니다.
ssh -O check host.example.com
당신은 모든 연결을 일거에 (특정 호스트에뿐만 아니라 연결), 삭제하려는 경우 fuser /tmp/ssh_mux_*또는 lsof /tmp/ssh_mux_*각 소켓을 제어하는 SSH 클라이언트를 나열합니다. 사용 fuser -HUP -k tmp/ssh_mux_*(이것은 클라이언트가 제대로 자신의 소켓을 제거 할 수 있습니다로 신호가 최선으로 SIGHUP를 사용하여) 깨끗하게 그들 모두를 죽일.
check내가 찾던 것보다 훨씬 유용 exit합니다. : D
fuser신호를 보낼 수 없지만 다음과 같이 작동합니다.lsof -Fp /tmp/ssh_mux_* | cut -c 2- | xargs kill -HUP
cmcControlMaster 세션을 관리하기 위한 오픈 소스 유틸리티 인 ClockworkNet / cmc를 작성했습니다 .
Usage: cmc [ -c HOST | -o HOST | -x HOST ]
cmc [ -L | -l | -O | -X ]
cmc -h
ControlMaster Controller - Eases management of SSH ControlMaster connections
Options:
-h show this help message and exit
-c HOST check HOST ControlMaster connection status (maybe specified more
than once)
-L list ControlMasters defined in SSH_CONFIG
-l list ControlMaster connection sockets in ~/.ssh/ and check their
connection status
-O open all ControlMasters defined in SSH_CONFIG
-o HOST open a ControlMaster session (maybe specified more than once)
-x HOST close ControlMaster session (maybe specified more than once)
-X exit all ControlMaster connections with sockets in ~/.ssh/
Notes:
* Any unopened sockets in ~/.ssh/ are removed with -l and -X
이것은 제어 마스터에 소켓 파일 만 사용하면 효과적입니다.
$ ssh -o ControlPath=~/.ssh/<controlfile> -O check <bogus arg>
다음은 이미 원격 서버에 연결 한 예입니다.
$ ssh -o ControlPath=~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check blah
Master running (pid=89228)
$
그리고 연결이 끊어졌습니다.
$ ssh -o ControlPath=~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O check blah
Control socket connect(/Users/user1/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74): No such file or directory
$
여전히 연결되어 있으면 즉시 종료됩니다.
$ ssh -o ControlPath=~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O exit blah
Exit request sent.
$
그것은 분명하지 않지만 ssh , blah내가 사용하는 스위치의 맥락에서 의미가 없지만 끝에 추가 인수가 필요하다는 잠재적 인 버그로 보입니다 .
그것이 없으면 나에게 이것을 준다 :
$ ssh -o ControlPath=~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port]
[-Q cipher | cipher-auth | mac | kex | key]
[-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] [user@]hostname [command]
$ ssh -V
OpenSSH_6.9p1, LibreSSL 2.1.8
CentOS 7.x
$ ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
나는이 두 가지 버전 모두 추가적인 가짜 주장이 필요하다는 것을 확인했다.
ssh -S none(아마도 이미 도움이 될 수 있습니다).