programing tip

비표준 포트로 원격 저장소 사용

itbloger 2020. 7. 12. 10:14
반응형

비표준 포트로 원격 저장소 사용


원격 저장소에 대한 로컬 자식 프로젝트를 설정하고 있습니다. 원격 저장소가 비표준 포트 (4019)에서 제공되고 있습니다.

그러나 작동하지 않습니다. 대신 다음과 같은 오류 메시지가 나타납니다.

ssh: connect to host git.host.de:4019 port 22: Connection refused
fatal: The remote end hung up unexpectedly
error: failed to push to 'ssh://root@git.host.de:4019/var/cache/git/project.git'

내 로컬 git 구성은 다음과 같습니다 .

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
[remote "origin"]
  url = ssh://root@git.host.de:4019/var/cache/git/project.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
  remote = origin
  merge = refs/heads/master

포트 및 호스트는 실제 포트 및 호스트의 자리 표시 자입니다.

내 자식 구성에 어떤 문제가 있습니까?


다음과 같은 것을 넣으면 .ssh/config:

Host githost
HostName git.host.de
Port 4019
User root

그런 다음 기본 구문을 사용할 수 있어야합니다.

git push githost:/var/cache/git/project.git master

SSH 기반 git access 방법은 http://git-scm.com/docs/git-clone에<repo_path>/.git/config 지정된 전체 URL 또는 SCP와 유사한 구문 사용하여 지정할 수 있습니다 .

URL 스타일 :

url = ssh://[user@]host.xz[:port]/path/to/repo.git/

SCP 스타일 :

url = [user@]host.xz:path/to/repo.git/

SCP 스타일은 ssh_config다음 ~/.ssh/config과 같은 호스트 정의에 의존하여 직접 포트 변경을 허용하지 않습니다 .

Host my_git_host
HostName git.some.host.org
Port 24589
User not_a_root_user

그런 다음 다음을 사용하여 쉘에서 테스트 할 수 있습니다.

ssh my_git_host

SCP 스타일 URI를 다음 <repo_path>/.git/config과 같이 변경하십시오 .

url = my_git_host:path/to/repo.git/

이 시도

git clone ssh://user@32.242.111.21:11111/home/git/repo.git

이렇게하면 직접 수정하는 대신 문제를 피할 수 있지만 ~/.ssh/config파일을 추가하고 이와 같은 것을 갖는 것이 좋습니다

Host git_host
HostName git.host.de
User root
Port 4019

그럼 당신은 가질 수 있습니다

url = git_host:/var/cache/git/project.git

당신은 또한 수 ssh git_hostscp git_host ...모든 것이 해결됩니다.


SSH는 :포트를 지정할 때 구문을 사용하지 않습니다 . 가장 쉬운 방법은 ~/.ssh/config파일 을 편집 하고 추가하는 것입니다.

호스트 git.host.de
  포트 4019

그런 다음 git.host.de포트 번호없이 지정하십시오 .

참고 URL : https://stackoverflow.com/questions/1558719/using-a-remote-repository-with-non-standard-port

반응형