LoginSignup
64

More than 5 years have passed since last update.

posted at

updated at

Githubにport:22 で push できなかった場合の対処法

VagrantのCentOS環境下で、originで指定したリモートへアクセスしようとしたところ、以下のようなエラーがでました。

$ git push -u origin master
ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly


そこで、公式のヘルプ
https://help.github.com/articles/using-ssh-over-the-https-port
にあるように Port:443 に接続してみます。

$ ssh -T -p 443 git@ssh.github.com

これだと接続できました。
次に、 Port:443 で接続するように設定ファイルを作ります。

$ vi ~/.ssh/config
Host github.com
    User git
    Hostname ssh.github.com
    Port 443
    IdentityFile ~/.ssh/id_rsa

identityFileはssh鍵のあるパスを指定します。そして、接続テストをします。

$ ssh -T git@github.com

ここで、接続できれば完了です。


もしかすると、こんなエラーが出るかもしれません。

Bad owner or permissions on /home/vagrant/.ssh/config

configファイルのアクセス権限に問題があるようなので、chmodコマンドを使って権限を書き換えます。

$ chmod 600 ~/.ssh/config

再度、接続テスト

$ ssh -T git@github.com

これで通りました。



参考文献
https://help.github.com/articles/using-ssh-over-the-https-port
http://mattn.kaoriya.net/software/20081029172540.htm
http://futuremix.org/2005/10/openssh-config-permission

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
64