close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_core.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
2009-02-28
- [備忘] 怎麼用 SSH 穿透 NAT 把服務送出來
- [做法]
- STEP 1: 用 ssh-copy-id 交換 SSH key - 幫忙加進 SERVER 的 .ssh/authorized_keys
jazz@PC:~$ ssh-keygen
jazz@PC:~$ ssh-copy-id .ssh/id_rsa.pub jazz@${SERVER}
- STEP 2: 在 PC 上定期用 crontab 跑 remote_ssh.sh 這隻 Script
jazz@PC:~$ cat remote_ssh.sh
#!/bin/bash
kill -9 $(pidof ssh)
nohup ssh -f -N -R 10000:localhost:22 jazz@${SERVER}
nohup ssh -f -N -R ${SERVER}:8123:localhost:80 jazz@${SERVER}
- STEP 3: 要達成使用行為二的目的,必須在 SERVER 上設定 /etc/ssh/sshd_config,加入 GatewayPorts yes 的描述
jazz@SERVER:~$ cat >> /etc/ssh/sshd_config < EOF
# SSH Port Forwarding
GatewayPorts yes
EOF
Cloud Computing
Download in other formats: