Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


개요

SSH Client 는 SSH Server 에 연결하는 용도외에 Port Forwarding 기능을 사용해서 Protocol tunneling 용도로도 사용할 수 있습니다.


예로 A(PC) <---------> B(SSH Server) <------------------------> C(Server) 구조의 서버가 네트워크가 있을때 A 에서 B 로는 들어가지만 C 로는 못 들어갈 경우가 있습니다.

...

Windows 사용자는 Windows 에 OpenSSH 설치 를 참고해서 설치하면 됩니다.

SSH tunneling

PC 가 있고 ssh있고 ssh-server(예: 192.168.10.20) 라는 서버가 있을 경우 다음 명령어로 모든 연결 요청을 요청을 ssh-server 로 포워딩할 수 있습니다.

SSH Client 설정

Code Block
languagebash
 ssh -D 8123 -f -C -q -N ssh-server


  • -D : -D [bind_address:]port

                 Specifies a local “dynamic” application-level port forwarding.  This works by allocating
                 a socket to listen to port on the local side, optionally bound to the specified
                 bind_address.  Whenever a connection is made to this port, the connection is forwarded
                 over the secure channel, and the application protocol is then used to determine where to
                 connect to from the remote machine.  Currently the SOCKS4 and SOCKS5 protocols are sup‐
                 ported, and ssh will act as a SOCKS server.  Only root can forward privileged ports.
                 Dynamic port forwardings can also be specified in the configuration file.

                 IPv6 addresses can be specified by enclosing the address in square brackets.  Only the
                 superuser can forward privileged ports.  By default, the local port is bound in accor‐
                 dance with the GatewayPorts setting.  However, an explicit bind_address may be used to
                 bind the connection to a specific address.  The bind_address of “localhost” indicates
                 that the listening port be bound for local use only, while an empty address or ‘*’ indi‐
                 cates that the port should be available from all interfacesdynamic port forwarding 용도로 binding할 포트를 지정하며 SOCK4와 SOCK5 를 지원합니다. 뒤에 지정한 포트 번호는 브라우저 설정에서 꼭 필요합니다.
  • -f   Requests ssh to go to background just before command execution.  This is useful if ssh

                 is going to ask for passwords or passphrases, but the user wants it in the background.
                 This implies -n.  The recommended way to start X11 programs at a remote site is with
                 something like ssh -f host xterm.

                 If the ExitOnForwardFailure configuration option is set to “yes”, then a client started
                 with -f will wait for all remote port forwards to be successfully established before
                 placing itself in the background.

  • -C:     Requests compression of all data (including stdin, stdout, stderr, and data for for‐
                 warded X11, TCP and UNIX-domain connections).  The compression algorithm is the same
                 used by gzip(1).  Compression is desirable on modem lines and other slow connections,
                 but will only slow down things on fast networks.  The default value can be set on a
                 host-by-host basis in the configuration files; see the Compression option.
  • -q:  Quiet mode.  Causes most warning and diagnostic messages to be suppressed.
  • -N:  Do not execute a remote command.  This is useful for just forwarding ports.

Browser 설정

...

  •  SSH 연결이 수립되면 ssh 프로그램을 백그라운드로 전환합닌다. port forwarding 용도로 사용할 때 유용한 옵션입니다.
  • -C:  모든 데이타를 압축해서 송수신합니다. 많은 데이타가 오가는 X11 forwarding 등의 경우에 유용합닌다.
  • -q:  워닝이나 진단 메시지등을 출력하지 않는 정숙 모드로 동작합니다.
  • -N:  Remote command 를 실행하지 않습니다. port forwarding 용도로 사용할 때 유용한 옵션입니다.


Browser 설정

웹 브라우저를 다음과 같이 설정하면 port forwarding 한 SSH 서버를 통해 연결할 수 있습니다.

파이어폭스 설정


Chrome

설정 에서 proxy 를 입력하고 프록시 설정 화면에 들어갑니다.

...

저장을 누른후에 브라우저가 정상 작동하는지 확인합니다.


같이 보기

Ref