본문 바로가기
🛠 DevOps & Tool/Git

[Git] git push ssh: connect to host github.com port 22: Connection timed out 에러

by 현주먹 2023. 9. 18.

 

에러

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

git push하는데 이런 오류가 발생했다..

회사에서 예제 커밋하는거라 방화벽에서 막았나? 생각했는데, 

다른 repo는 push가 잘됐다..;

 

해결 실패

검색해서 아래 2가지 방법을 따라해봤는데 안됐다.

1. 

$ vim ~/.ssh/config

아래 내용을 추가
Host github.com
Hostname ssh.github.com
Port 443

2.

// 1. remote 주소 삭제
$ git remote remove [원격 저장소명]

// 2. remote 주소 추가
$ git remote add [원격 저장소명] [url주소]

// 3. remote 주소 확인
$ git remote -v

 

해결

1) 현재 git remote 연결 주소 확인

$ git remote -v

이렇게 나온다.

origin git@github.com:/git아이디/commitTest.git (fetch)
origin git@github.com:/git아이디/commitTest.git (push)

 

2. git remote url 변경하기 

$ git remote set-url origin https://github.com/내git아이디/commitTest.git

 

3. git push

$ git push origin master

잘되는 것을 확인할 수 있다.

Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 16 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 1.08 KiB | 1.08 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/git아이디/commitTest.git
 * [new branch]      master -> master