CentOS6.3でsshをproxy経由で使用する方法

だいたいWin7でやったことと同じ。

Githubアカウントを作る。(省略)

SSH keypairを作りGithubへ登録。

$ ssh-keygen -t rsa -C "自分のメールアドレス"

「~/.ssh」配下に諸々の鍵が生成。GithubSSH Keysページhttps://github.com/settings/sshからpublic key(id_rsa.pub)を登録。

接続テスト→失敗(省略)

proxy超えをするための設定

「~/.ssh」配下にconfigを作成。以下を記述する。
先に補足すると

    • connectをどこかから入手する。
    • ★proxy.example.com:port★は各々の環境に合わせて書き換える。

参考。こちらSSH through HTTP proxy

$ vim /etc/ssh/sshd_config

Port 443

再起動も忘れずに

$ sudo /etc/init.d/ssh restart

connectを入手しましょう

$ wget http://www.meadowy.org/~gotoh/ssh/connect.c
$ gcc connect.c -o connect
$ sudo cp connect /usr/local/bin/ ; chmod +x /usr/local/bin/connect

~/.ssh/configファイルを編集する

ProxyCommand connect -H ★proxy.example.com:port★ %h %p

Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes

Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes

接続テスト〜そして成功へ

$ ssh git@github.com

Warning: Permanently added '[ssh.github.com]:443' (RSA) to the list of known hosts.
Hi ★★★(名前ね)! You've successfully authenticated, but GitHub does not provide shell access.
Connection to ssh.github.com closed.

Win7版と違ってconnectを自分で用意する必要があるので注意。お疲れ様でした。