2007
01
23
23
46
安裝 cygwin 下的 sshd 以及設定 tunnel.
先去 cygwin 的網站下載 setup.exe ,用 setup.exe 安裝 sshd 。
大概照著指示,不會有什麼大問題。
安裝完畢後,使用 ssh-host-config 設定。
Should privilege separation be used? (yes/no)no
如果你是yes。會例外再建立名為sshd的使用者。
Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no)no
我不喜歡安裝成service。
事後可以用
cygrunsrv.exe --install sshd --path /usr/sbin/sshd.exe --disp "CYGWIN SSHD" --args "-D" --env CYGWIN="ntsec tty"
去安裝成 Service.
cygrunsrv --start sshd
啟動這個 Service
或者
cygrunsrv --remove sshd
移除這個 Service
另外修改 /etc/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
IgnoreRhosts yes
PasswordAuthentication no
用 Authorized key file 來 login.
所以,在你的工作目錄下執行 ssh-keygen
預設值會在你的home directory下建立 .ssh 的目錄,
以及 id_rsa 和 id_rsa.pub 兩個檔案。
到 .ssh 目錄下把 id_rsa.pub 更名為 authorized_keys。
然後把 id_rsa 拷貝出來。
用 putty 的 puttygen.exe,
把 id_rsa 載入後,另存新檔 xxx.ppk。
這個檔案是稍後要登入 sshd 的 private key。
然後就把 putty.exe 執行起來。
選取 Session
填入 Host Name (or IP address)
Protocol 當然是 SSH
取個 Saved Sessions
選取 Connection => SSH => Auth
按下 Browse... 選取 剛剛的 private key xxx.ppk
選取 Connection => SSH => Tunnels
如果 tunnel 要給其他 host 使用,
請把這個選取起來 Local ports accept connections from other hosts
選取 Dynamic ,
然後給個 Source port,我喜歡用 1080 然後按下 Add.
再回到 Session
把剛剛的 Save 起來。
剩下就按下 Open 應該就可以登入 sshd。
這是用 putty 登入。
用來自動化,可能不太方便。
所以,需要用 putty 的另一隻程式 plink.exe,
只要執行 plink -load "Saved Sessions"
這裡的 Saved Sessions 是之前的名稱。
plink 會用剛剛的設定來連線。
至於瀏覽器,只需要在設定 Proxy 的部份,
設定 Socks Server 和 Port 。
就可以使用了。