하나의 명령으로 모든 SSH 연결을 종료하고 PuTTY를 닫습니다.

하나의 명령으로 모든 SSH 연결을 종료하고 PuTTY를 닫습니다.

모든 SSH 연결을 취소하고 닫는 방법이 있습니까?퍼티"원샷"으로? 저는 Windows 7에서 작업하고 PuTTY를 사용하여 다양한 Linux 호스트에 SSH로 연결합니다.

내가 일하는 방식의 예:

SSH to host1 with PuTTY...
banjer@host1:~> #...doin some work...ooh! need to go check something on host8...
banjer@host1:~> ssh host8
banjer@host8:~> #...doin some work...OK time for lunch. lets close putty...
banjer@host8:~> exit
banjer@host1:~> exit
Putty closes.

위의 내용에 따르면, Host8에서 PuTTY를 한 번에 닫을 수 있는 방법이 있습니까? 때때로 나는 최대 5~10개의 호스트 깊이를 발견합니다. X를 클릭하여 PuTTY 창을 닫을 수 있다는 것을 알고 있지만, 종료 명령을 사용하여 SSH 연결이 제대로 닫히는지 확인하고 싶습니다. 나는 또한 게으름을 늘리는 방법에 대한 조언을 구하고 있다는 것을 깨달았습니다. 그냥 "어떻게 하면 더 효율적일 수 있을까"라고 적어보겠습니다.

답변1

연결 종료 이스케이프 시퀀스를 사용해 보십시오 ssh.

세션 에서 (물결표)를 ssh입력합니다 . ~.문자를 입력하면 문자가 표시되지 않지만 세션은 즉시 종료됩니다.

$ ~.
$ Connection to me.myhost.com closed.  

에서man 1 ssh

The supported escapes (assuming the default ‘~’) are:
 ~.      Disconnect.
 ~^Z     Background ssh.
 ~#      List forwarded connections.
 ~&      Background ssh at logout when waiting for forwarded 
         connection / X11 sessions to terminate.
 ~?      Display a list of escape characters.
 ~B      Send a BREAK to the remote system (only useful for SSH protocol
         version 2 and if the peer supports it).
 ~C      Open command line.  Currently this allows the addition of port 
         forwardings using the -L, -R and -D options (see above). It also
         allows the cancellation of existing remote port-forwardings using 
         -KR[bind_address:]port.  !command allows the user to execute a 
         local command if the PermitLocalCommand option is enabled in
         ssh_config(5).  Basic help is available, using the -h option.
 ~R      Request rekeying of the connection (only useful for SSH protocol 
         version 2 and if the peer supports it).

답변2

Ctrl+를 눌러 D종료하면 로그아웃됩니다. 창이 사라질 때까지 여러 창, 탭 또는 레벨에서 로그아웃하려면 길게 누르기를 반복해서 Ctrl누르세요 .D

답변3

PuTTY를 닫으면 됩니다. ( Alt+ F4기본적으로 IIRC입니다.)

답변4

function또 다른 방법은 다음을 만드는 것입니다 ssh.

   function ssh(){ /usr/bin/ssh $@ ; exit ; } 

불행하게도 원격 시스템에서 작업을 마친 후에는 항상 연결을 닫고 콘솔에서 로그아웃합니다.

모든 서버에서 이러한 기능을 만들어야 한다는 점에 유의하세요. 그렇지 않으면 이 핵이 작동하지 않습니다. 그런데 언제든지 ~/.bashrc 또는 ~/.whatever_shell_you_use_rc 에 함수를 넣을 수 있습니다.

uther의 방식과 비교하면 약간 더러운 해킹처럼 보입니다.

관련 정보