./ssh/config 파일을 사용하여 역방향 SSH 터널을 어떻게 설정합니까?
이 명령을 재현하려고 합니다.
ssh -R 55555:localhost:22 user@host
내 .ssh/config 파일에 입력하면 ssh host
역방향 터널을 사용하여 사용자로 호스트에 SSH로 연결됩니다. 구성 파일에서 허용하는 명령은 명령줄 플래그에 비해 더 자세한 내용입니다. ssh 맨페이지와 ssh_config 맨페이지를 보면 해당 설정이 BindAddress인 것 같습니다.
내 .ssh/config 파일에는 다음이 있습니다.
Host host
Hostname host
User user
BindAddress 55555:localhost:22
이것과 약간의 변형으로 인해 시도할 때 연결이 거부됩니다.
ssh localhost -p 55555
호스트에 로그인한 후 호스트에 처음 SSH로 연결할 때 상단에 명시적으로 명령을 지정하면 똑같이 잘 작동합니다. 내 구성 파일은 역방향 터널 명령 없이 작동합니다. ssh host
나를 호스트에 사용자로 로그인합니다.
답변1
BindAddress
당신이 원하는 옵션이 아닙니다. 에서man ssh_config
:
BindAddress
Use the specified address on the local machine as the source
address of the connection. Only useful on systems with more than
one address.
에 해당하는 구성 파일은 -R
다음 과 같습니다 RemoteForward
.
RemoteForward
Specifies that a TCP port on the remote machine be forwarded over
the secure channel to the specified host and port from the local
machine. The first argument must be [bind_address:]port and the
second argument must be host:hostport. [...]
이 정보를 사용하여 명령줄
ssh -R 55555:localhost:22 user@host
다음 .ssh/config
구문으로 변환됩니다.
Host host
HostName host
User user
RemoteForward 55555 localhost:22