OpenSSH 7.3이상

OpenSSH 7.3이상

브리지 서버를 통해 서버로 터널링하려고 합니다. 지금까지 다음을 사용하여 명령 셸에서 작동하도록 할 수 있었습니다.

ssh -A -t [email protected] ssh -A [email protected]

하지만 그것을 내 파일로 패키징하려고 했는데 ~/.ssh/config문제가 발생했습니다. 나는 시도했다:

Host axp
  User          remote_userid
  HostName      remoteserver.com
  IdentityFile  ~/.ssh/id_rsa.eric
  ProxyCommand ssh -A -t bridge_userid@bridge_userid.com ssh -A remote_userid@%h

하지만 이 작업을 수행하면 다음과 같은 오류 메시지가 표시되며 remoteserver.com, 원인이 무엇인지 잘 모르겠습니다.

ksh: SSH-2.0-OpenSSH_6.8^M: 찾을 수 없음

나는 로그인할 때 remoteserver.com내 쉘이 이라는 것을 알고 있습니다 /usr/bin/ksh.

구성 파일의 ssh 명령에 경로 매개변수를 추가하려고 시도했지만 아무런 차이가 없었습니다.

어떤 아이디어가 있나요?

답변1

Jakujie의 답변맞습니다. 하지만 OpenSSH 이후로 이제 더 쉬운 방법을 7.3사용할 수 있습니다 . -J ProxyJump내 메모 보기:

OpenSSH 7.3이상

사용 ProxyJump. 설명서에 설명된 대로:

-J [user@]host[:port]
먼저 점프 호스트에 대한 SSH 연결을 설정한 다음 그곳에서 최종 대상으로 TCP 전달을 설정하여 대상 호스트에 연결합니다. 여러 점프를 쉼표로 구분하여 지정할 수 있습니다. 이는 ProxyJump 구성 지시문을 지정하는 바로가기입니다.

ProxyJump ~/.ssh/config

~/.ssh/config

Host server1
  Hostname server1.example.com
  IdentityFile ~/.ssh/id_rsa

Host server2_behind_server1
  Hostname server2.example.com
  IdentityFile ~/.ssh/id_rsa
  ProxyJump server1

~와 연결하다

ssh server2_behind_server1 -v

-v자세한 출력 추가

ProxyJump -J명령줄 예

~/.ssh/config

Host server1
  Hostname server1.example.com
  IdentityFile ~/.ssh/id_rsa

Host server2
  Hostname server2.example.com
  IdentityFile ~/.ssh/id_rsa

~와 연결하다

ssh server2 -J server1 -v

또는 사용-o

ssh server2 -o 'ProxyJump server1' -v

OpenSSH 5.4이상

ProxyCommand그리고 사용-W

~/.ssh/config

Host server1
  Hostname server1.example.com
  IdentityFile ~/.ssh/id_rsa

Host server2
  Hostname server2.example.com
  IdentityFile ~/.ssh/id_rsa
  ProxyCommand ssh server1 -W %h:%p

~와 연결하다

ssh server2 -v

또는 사용-o

ssh server2 -o 'ProxyCommand ssh server1 -W %h:%p' -v

OpenSSH는 다음과 같습니다5.4

~/.ssh/config

Host server1
  Hostname server1.example.com
  IdentityFile ~/.ssh/id_rsa

Host server2
  Hostname server2.example.com
  IdentityFile ~/.ssh/id_rsa
  ProxyCommand ssh server1 nc %h %p 2> /dev/null

와 연결하다:

ssh server2 -v

또는 사용-o

ssh server2 -o 'ProxyCommand ssh server1 nc %h %p 2> /dev/null' -v

원천

-J에 추가하다오픈SSH 7.3

  • ssh(1): 하나 이상의 SSH 요새 또는 "점프 호스트"를 통해 단순화된 간접 액세스를 허용하려면 ProxyJump 옵션 및 해당 -J 명령줄 플래그를 추가합니다.

-W에 추가하다오픈SSH 5.4

  • ssh(1)에 "netcat 모드"를 추가했습니다: "ssh -W 호스트:포트 ..." 이는 클라이언트의 stdio를 서버의 단일 포트 전달에 연결합니다. 예를 들어, ssh를 ProxyCommand로 사용하여 중간 서버를 통해 연결을 라우팅할 수 있습니다. bz#1618

답변2

netcat다리 위에 있을 필요는 없습니다 . DanSut이 의견에서 제안한 대로 명령줄 옵션을 사용할 수 ssh -W있으며 이 구성이 적합합니다.

Host axp
  User          remote_userid
  HostName      remoteserver.com
  IdentityFile  ~/.ssh/id_rsa.eric
  ProxyCommand ssh -AW %h:%p bridge_userid@bridge_userid.com

관련 정보