星期四, 元月 28, 2010

Linux 透過 SSH SOCKS 連線 來 使用 Firefox / Pidgin(MSN, GTalk..)

現在不少醫院都有無線網路, 但是使用後, 體驗被限制只有開 80, 443 Port 的感覺.

但是我在這邊最少要待三天, 陪產(n天) + 生產完(3~7天), 至少要讓 SSH、MSN 能通才行.

  • 註1: 於 Ubuntu Linux, Windows 可以利用 Putty 來達成.
  • 註2: 此篇重點 sudo ssh -D 80 user@example.com -p 443
  • 註3: 在醫院連國外網站(ex: YouTube 被擋掉的話),透過自己的 Server 當 Proxy 會快很多. XD

基礎環境

首先, 要先找好朋友, 幫忙弄台 Server, 讓 ssh port 加開 80 或 443 Port. (沒有這個, 後續就不用玩了. XD)

  1. vim /etc/ssh/sshd_config
    Port 22 # 於這下面加上下述即可.
    Port 443
  2. /etc/init.d/ssh restart # 22, 443 就都可以連進此 Server. (可同時開兩個 Port)

使用 ssh -D 來建立 SOCKS

於 Localhost 開啟 80 Port, 與遠端(example.com)的 443 Port 串起來.

  1. netstat -tln | grep 80 # 先看看 localhost 有沒有佔用 80 Port, 若有佔用, 需要停掉.
  2. sudo ssh -D 80 user@example.com -p 443 # 80 Port 需要 root 權限.
  3. 連線進去後, 只要將此連線留著, 不要關掉即可.

Firefox 透過 SOCKS 連線

  1. 編輯 -> 偏好設定
  2. 進階 -> 網路 -> 設定(連線, 設定 Firefox 要如何連到網路)
  3. 手動設定 Proxy -> SOCKS 主機
    • 127.0.0.1
    • 80 # 看 localhost 設得 Port
    • 確定 # 測試是否可以連線, 若可以正常瀏覽網頁, 代表透過 SSH 是通得.

Pidgin 透過 SOCKS5 連線

  1. 帳號 -> 編輯帳號 # MSN / Gtalk 都一樣設定法.
  2. 代理伺服器
    • SOCKS 5
    • 127.0.0.1
    • 80 # 看 localhost 設得 Port
    • 儲存 # 即可連線

相關網頁

相關標籤

this is comment icon 要不要用那個.... [回覆]

要不要用那個試試看?

Comment by git trac (01/30/2010 07:55)

this is comment icon DNS 也要用遠端的 [回覆]

這樣做有時候遠端 DNS 跟 local 會有問題
1. Open up firefox
2. Type about:config on the location bar
3. Filter for the following: network.proxy.socks_remote_dns
4. Set the value to True (Right Click on the value in the column)
5. Restart Firefox

Comment by jvincent (01/30/2010 09:04)

this is comment icon OpenVPN? [回覆]

我都用家裡架OpenVPN server開在443 port. Windows直接用VPN拉回家再出去. 只要443沒被檔. 甚麼都可以通. 還有加密效果. 給您參考. ^^

Comment by Treker (01/30/2010 10:52)

this is comment icon 回 Treker [回覆]

jon

嗯嗯, 感恩~
我有在考慮要架一個, 可以省掉不少麻煩~ :D

Comment by Tsung (01/31/2010 16:12)

this is comment icon 回 jvincent [回覆]

jon

我通常是直接改 /etc/resolv.conf.
不過你這方法直接改 Firefox 的很酷~ 感恩 :D

Comment by Tsung (01/31/2010 16:13)
Add this page to del.icio.us

發表迴響

標題

內容 (限制 1000 字)

暱稱

電子郵件

個人網頁


 authimage


PS: 若無法留言, 請先確認是否有打開 JavaScript, 造成您的困擾, 實在萬分對不起 Orz...(如果無法留言, 勞煩可以發信給我好嗎? 謝謝.)
PS2: 若您的留言被誤判, 我都會再自行看過, 不需要一直重覆張貼~