SSH를 통한 원스텝 클라이언트 VNC 연결(예: -via 옵션 사용)

SSH를 통한 원스텝 클라이언트 VNC 연결(예: -via 옵션 사용)

이 두 명령을 하나로 어떻게 줄일 수 있습니까? 클라이언트에서 x11vnc 서버에 연결 중인데 아래 두 명령이 이미 작동하고 있습니다. 나는 단계별로 그것을하고 싶습니다 :

첫 번째 명령:

ssh -fNL 5901:localhost:5678 -i ~/.ssh/some_id_rsa [email protected]

두번째:

vncviewer localhost:5901

매뉴얼 페이지를 읽어보면 -via 옵션이 이 작업을 수행하는 것으로 보입니다. 불행하게도 매뉴얼 페이지는 나를 매우 혼란스럽게 합니다. 참고로(내가 이해한 것은 아님) 내 매뉴얼 페이지에 다음과 같이 나와 있습니다.

   -via gateway
          Automatically create encrypted TCP tunnel to the gateway machine before con‐
          nection, connect to the host through  that  tunnel  (TightVNC-specific).  By
          default,  this  option  invokes SSH local port forwarding, assuming that SSH
          client binary can be accessed as /usr/bin/ssh. Note that when using the -via
          option,  the  host  machine name should be specified as known to the gateway
          machine, e.g.  "localhost"  denotes  the  gateway,  not  the  machine  where
          vncviewer  was  launched.  The environment variable VNC_VIA_CMD can override
          the            default             tunnel             command             of
          /usr/bin/ssh -f -L "$L":"$H":"$R" "$G" sleep 20.  The tunnel command is exe‐
          cuted with the environment variables L, H, R, and G taken the values of  the
          local  port number, the remote host, the port number on the remote host, and
          the gateway machine respectively.

답변1

이것이 매뉴얼 페이지가 말하려는 것입니다. 다음 설정이 있습니다.

  vncviewer         .-,(  ),-.    
   __  _         .-(          )-.           gateway           vncserver 
  [__]|=|  ---->(    internet    )-------> __________ ------> ____   __ 
  /::/|_|        '-(          ).-'        [_...__...°]       |    | |==|
                     '-.( ).-'                               |____| |  |
                                                             /::::/ |__|

노트:위의 그림은 다음을 사용하여 완성되었습니다.아스키.

vncviewer내 노트북에서 실행 중입니다 . 내 노트북에서 다음 명령을 실행하고 vncserver라우터 뒤에 있는 명령에 연결할 수 있습니다.

$ vncviewer vncserver_host:0 -via mygateway.mydom.com

그러면 즉시 에 연결됩니다 vncserver. 이 명령은 내 노트북에 표시되며 매뉴얼 페이지에서 설명하려는 내용을 보여주는 데 도움이 됩니다.

/usr/bin/ssh -f -L 5599:vncserver_host:5900 mygateway.mydom.com sleep 20

vncviewer스위치 사용시 자동으로 빌드되는 명령어입니다 -via gateway.

ssh구성 포함

~/.ssh/config해당 파일을 사용하여 다음과 같이 항목을 넣을 수 있습니다.

Host *
IdentityFile ~/.ssh/id_dsa

또는 다음과 같이 특정 호스트를 타겟팅할 수 있습니다.

Host mygateway
    User sam
    HostName mygateway.mydom.com
    IdentityFile ~/.ssh/someother_id_rsa

Host이렇게 하면 이 파일의 항목을 다음과 같이 활용할 수 있습니다.

$ vncviewer vncserver_host:0 -via mygateway

관련 정보