0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Git】connect to host github.com port 22で怒られた場合の対処法

Last updated at Posted at 2023-10-15

はじめに

外で仕事をしていたりすると、たまにgitに怒られる場合があります。
まさにタイトルと同じエラーなのですが、毎度解消法を検索するのは手間なので備忘録的に残しておこうと思います。

portで怒られた場合の解消方法

使用するネットワーク環境によってはport22を許容していないケースがあるようで、これが原因のようです。
対処法としては公式ドキュメントに記載のある手順で解消が可能です。

まず、原因であるport22に代わるport443で接続できるか確認します。

$ ssh -T -p 443 git@ssh.github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

次にsshディレクトリ内にあるconfigファイルを公式に従って編集します。

$ vi ~/.ssh/config

//以下のとおり記載
Host github.com
   User git
   Hostname ssh.github.com
   Port 443
   IdentityFile ~/.ssh/id_rsa

最後に正常に接続が可能か確認します。

$ ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

以上になります。
無事接続ができればエラーは解消しているはずです。

さいごに

たまにこの手のぱっと見ではよくわからないエラーに遭遇するのがgitあるあるではないでしょうか?
出先で遭遇すると余計にあたふたしそうなので、また似たような事象に遭遇したら記事にまとめておこうと思います。

0
1
0

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
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?