SSH Tunneling Related
Reference Material: http://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/
Local Port forwarding:
- Scenario: The initiator can connect to the Ssh_server_host-side SSH service, but cannot communicate directly with the program of the final target goal_host, and Ssh_server_host can
- Command format: SSH [-g]-l <local_port>:<goal_host>:<goal_port> [email protected]<ssh_server_host>
- Local_port: The host port number that originally originated the connection
- Goal_host: The IP or hostname of the final destination host, which can be the same machine as ssh_server_host (at this point the goal_host is usually set to localhost or 127.0.0.1)
- Goal_port: Port number of the final destination host
- Ssh_server_host: The intermediate host that is responsible for SSH forwarding
- -G: This option allows other hosts to connect remotely to the Local_port port on the first host, which is equivalent to adding additional communication nodes
Remote Port forwarding:
- Applicable scenario: The initiator cannot connect to the Ssh_server_host end of the SSH service (such as: The initiator is an extranet host, but Ssh_server_host is the intranet host after Nat), but the reverse connection is allowed, and ssh_server_host can be with the final target G Direct communication of programs on Oal_host
- Command format: SSH [-g]-R <remote_port>:<goal_host>:<goal_port> [email protected]<ssh_server_host>
- Remote_host: The host port number that originally originated the connection, where remote is relative to ssh_server_host, because this operation needs to be done on ssh_server_host
- Goal_host: The IP or host name of the final destination host, which can be the native of the operation of this command
- Goal_port: Port number of the final destination host
- Ssh_server_host: This refers to the host IP or hostname from which the connection originated, since the SSH connection is made by an intermediary host, the initial host audited the role of the SSH server
Target Host:
#!/bin/bash#dynamic domain name:fanhui.f3322.net#url:http://www.pubyun.comhttp://www.3322.netkeep_alive () { while : DoCount=$(PSAx |grep-C"ssh-gntr 9527:localhost:22 [email protected]") if[[$count-lt2 ]] Then suFh-c"ssh-gntr 9527:localhost:22 [email protected]" fi Sleep300s Done}keep_alive>/dev/NULL 2>&1&
Cloud (SSH Broker):
#!/bin/Bash while : DoLynx-mime_header-auth=kitex:aibbigql"http://members.3322.net/dyndns/update?system=dyndns&hostname=fanhui.f3322.net" 2>/dev/NULLIp_0=$ (Curl http://Members.3322.org/dyndns/getip) Sleep600s ip_1=$ (Curl http://Members.3322.org/dyndns/getip) while[[$Ip _1-eq $Ip _0]] Do Sleep600s ip_1=$ (Curl http://Members.3322.org/dyndns/getip) Done Done
Linux Basic notes--[023]--"openssh tunneling"