1.6. SSH 건너뛰기 호스트를 통해 원격 서버에 연결
건너뛰기 호스트라고도 하는 중간 서버를 통해 로컬 시스템에서 원격 서버에 연결할 수 있습니다. 건너뛰기 서버는 다른 보안 영역의 호스트를 브리지하고 여러 클라이언트-서버 연결을 관리할 수 있습니다.
사전 요구 사항
- 건너뛰기 호스트는 로컬 시스템의 SSH 연결을 허용합니다.
- 원격 서버는 건너뛰기 호스트의 SSH 연결을 허용합니다.
프로세스
건너뛰기 서버 또는 중간 서버를 한 번 이상 통해 연결하는 경우
ssh -J
명령을 사용하여 건너뛰기 서버를 직접 지정합니다. 예를 들면 다음과 같습니다.ssh -J <jump-1.example.com>,<jump-2.example.com>,<jump-3.example.com> <target-server-1.example.com>
$ ssh -J <jump-1.example.com>,<jump-2.example.com>,<jump-3.example.com> <target-server-1.example.com>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 건너뛰기 서버의 사용자 이름 또는 SSH 포트가 원격 서버의 이름과 포트와 다른 경우 이전 명령에서 호스트 이름 전용 표기법을 변경합니다. 예를 들면 다음과 같습니다.
ssh -J <example.user.1>@<jump-1.example.com>:<75>,<example.user.2>@<jump-2.example.com>:<75>,<example.user.3>@<jump-3.example.com>:<75> <example.user.f>@<target-server-1.example.com>:<220>
$ ssh -J <example.user.1>@<jump-1.example.com>:<75>,<example.user.2>@<jump-2.example.com>:<75>,<example.user.3>@<jump-3.example.com>:<75> <example.user.f>@<target-server-1.example.com>:<220>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 건너뛰기를 정기적으로 서버를 통해 원격 서버에 연결하면 ssh 구성 파일에 jump-server 구성을 저장합니다.
로컬 시스템에서
~/.ssh/config
파일을 편집하여 건너뛰기를 정의합니다. 예를 들면 다음과 같습니다.Host <jump-server-1> HostName <jump-1.example.com>
Host <jump-server-1> HostName <jump-1.example.com>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Host
매개 변수는ssh
명령에서 사용할 수 있는 호스트의 이름 또는 별칭을 정의합니다. 이 값은 실제 호스트 이름과 일치할 수 있지만 임의의 문자열일 수도 있습니다. -
HostName
매개 변수는 건너뛰기 호스트의 실제 호스트 이름 또는 IP 주소를 설정합니다.
-
ProxyJump
지시문을 사용하여 원격 서버 건너뛰기를 로컬 시스템의~/.ssh/config
파일에 추가합니다. 예를 들면 다음과 같습니다.Host <remote-server-1> HostName <target-server-1.example.com> ProxyJump <jump-server-1>
Host <remote-server-1> HostName <target-server-1.example.com> ProxyJump <jump-server-1>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 로컬 시스템을 사용하여 이동 서버를 통해 원격 서버에 연결합니다.
ssh <remote-server-1>
$ ssh <remote-server-1>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 이 명령은 이전 구성 단계를 생략하는 경우
ssh -J jump-server1 remote-server
명령과 동일합니다.