로컬 네트워크에서는 SSH 연결이 불가능합니다

로컬 네트워크에서는 SSH 연결이 불가능합니다

오늘 저는 아주 이상한 사실을 깨달았습니다.

내 로컬 네트워크에 인터넷을 통해 SSH 포트에 액세스할 수 있는 서버(Ubuntu Server 12.04.4 LTS 실행)가 있습니다( 를 사용하여 연결할 수 있음 ssh my.internet.ip.address).

하지만 로컬 네트워크에서 연결할 수 없다는 사실을 오늘에서야 깨달았습니다( ssh its.local.ip.address오류 없이 실패함).

/etc/hosts.deny에서 내 컴퓨터를 명시적으로 확인 하고 추가했지만 /etc/hosts.allow이로 인해 아무것도 변경되지 않았습니다. 물론 ssh와 전체 서버도 다시 시작해 보았습니다. 사용 가능한 새 업데이트가 없습니다.

로컬 연결 실패:

myself@my-desktop ~ $ ssh -v its.local.ip.address
OpenSSH_6.2p2 Ubuntu-6ubuntu0.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to its.local.ip.address [its.local.ip.address] port 22.
debug1: Connection established.
debug1: identity file /home/myself/.ssh/id_rsa type -1
debug1: identity file /home/myself/.ssh/id_rsa-cert type -1
debug1: identity file /home/myself/.ssh/id_dsa type -1
debug1: identity file /home/myself/.ssh/id_dsa-cert type -1
debug1: identity file /home/myself/.ssh/id_ecdsa type -1
debug1: identity file /home/myself/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2p2 Ubuntu-6ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
Connection closed by its.local.ip.address
myself@my-desktop ~ $ 

그러나 원격 연결은 작동합니다.

myself@my-desktop ~ $ ssh -v my.internet.ip.address
OpenSSH_6.2p2 Ubuntu-6ubuntu0.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to my.internet.ip.address [my.internet.ip.address] port 22.
debug1: Connection established.
debug1: identity file /home/myself/.ssh/id_rsa type -1
debug1: identity file /home/myself/.ssh/id_rsa-cert type -1
debug1: identity file /home/myself/.ssh/id_dsa type -1
debug1: identity file /home/myself/.ssh/id_dsa-cert type -1
debug1: identity file /home/myself/.ssh/id_ecdsa type -1
debug1: identity file /home/myself/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2p2 Ubuntu-6ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA [... hidden here ...]
debug1: Host 'my.internet.ip.address' is known and matches the ECDSA host key.
debug1: Found key in /home/myself/.ssh/known_hosts:4
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
[email protected]'s password: 
[ ... everything works just fine ... ]

이 문제의 원인은 무엇이며, 더 중요한 문제는 어떻게 해결할 수 있습니까?

참고: 자세한 내용( ssh -vvv)을 늘리면 두 출력이 모두 벗어나는 지점에서 추가 항목이 표시되지 않습니다.

답변1

서버가 연결을 끊기로 결정했기 때문에 서버 측에서 문제를 디버깅해야 합니다. 서버에 대한 "루트" 액세스 권한이 있는 경우 sshd대화식으로 실행할 수 있습니다.

/path/to/sshd -ddd -p 42

sshd이렇게 하면 디버그 모드에서 포트 42에서 수신 대기 복사본이 실행됩니다. 다른 번호를 지정할 수 있습니다. 이는 포그라운드에서 실행되어 단일 연결을 허용하고 디버깅 정보를 터미널에 인쇄합니다.

이제 클라이언트와 연결하세요.

ssh -v -p 42 its.local.ip.address

운이 좋으면 서버 측 디버깅 메시지에 세션이 삭제되는 이유가 표시되어야 합니다.

답변2

나는 클라이언트 시스템이 두 캡처 모두에서 동일하다고 가정합니다(프롬트는 다르지만) TCP 연결을 허용하므로 아마도 역방향 DNS 및/또는 sshd 구성의 정책 거부와 관련이 있을 것입니다.

서버 측에서 DNS를 끄고(sshd_config에서 UseDNS=no) sshd를 다시 시작해 보십시오(kill -1이면 충분합니다).

답변3

이 버그는 다중 사용자에게 영향을 미친 것으로 보고되었습니다.

로컬인 경우 ssh -X를 시도하여 x 전달을 비활성화합니다.

또한 최대 전송 단위[MTU]를 ssh_server의 MTU에 맞게 조정해야 할 수도 있습니다.

** 로컬에서 작동하지 않으면 다음을 시도하십시오.

 myself@my-desktop ~ $ ssh -v my.internet.ip.address

네트워크 밖으로 이동할 수 있으면 다시 들어오세요.

서버 구성 오류일 수 있습니다. sshd_config에서 "허용된 사용자"를 확인하고, Known_host가 저장되는 위치를 확인하고, 사용자 "myself"의 local.ip.address 버전을 추가하세요.

sshd 사본이 도움이 될 수 있습니다

관련 정보