Debian 호스트에서 VirtualBox CentOS 7 게스트로 SSH를 통해 연결할 수 없습니다.

Debian 호스트에서 VirtualBox CentOS 7 게스트로 SSH를 통해 연결할 수 없습니다.

데비안 9 호스트가 있습니다. 문제 없이 Raspberry Pi 및 기타 서버에 SSH로 접속할 수 있습니다. VirtualBox에 가상 머신으로 openSUSE를 설치했습니다. 문제 없이 해당 가상 머신에 SSH로 접속할 수 있습니다. VirtualBox에서 이를 설정하기 위해 설정 > 네트워크 > 고급 > 포트 전달 > 이름: ssh, 프로토콜: TCP, 호스트 IP: (공백), 호스트 포트: (임의의 높은 포트 번호), 게스트 IP: (공백)로 이동했습니다. ), 게스트 포트: 22. 이는 어댑터 1용이며 "연결 대상: NAT"입니다. 이러한 지침은 몇 가지 다른 포럼 게시물에 나와 있습니다. 내 CentOS 가상 머신에 대해 동일한 작업을 수행했지만 다른 호스트 포트(임의의 높은 포트 번호)를 사용했습니다. sshd 서비스가 sudo systemctl status sshd. 그러나 CentOS 가상 머신에 SSH로 접속할 수 없습니다. 다음 오류가 발생합니다(아래 마지막 줄).

~$ ssh -p 1820 [email protected] -v
OpenSSH_7.4p1 Debian-10, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1820.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/brock/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Debian-10
ssh_exchange_identification: read: Connection reset by peer

문제는 CentOS가 네트워킹 또는 SSH에 대해 구성되는 방식과 관련이 있습니다. CentOS VM은 인터넷 연결에 문제가 없습니다. VirtualBox를 사용하는 사람에게는 이것이 쉬운 테스트가 될 수 있을 것 같습니다. 그만큼CentOS 최소 iso680MB입니다.

/var/log/secure다음은 내 사용자와 루트 모두를 사용하여 ssh를 시도했을 때의 오늘 출력 입니다 .

May 31 00:58:03 localhost sshd[1141]: Server listening on 0.0.0.0 port 22.
May 31 00:58:03 localhost sshd[1141]: Server listening on :: port 22.
May 31 00:58:14 localhost login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
May 31 00:58:14 localhost login: ROOT LOGIN ON tty1
May 31 00:58:22 localhost polkitd[656]: Registered Authentication Agent for unix-process:2529:3738 (system bus name :1.30 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 00:58:23 localhost login: pam_unix(login:session): session closed for user root
May 31 00:58:23 localhost polkitd[656]: Unregistered Authentication Agent for unix-process:2529:3738 (system bus name :1.30, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
May 31 00:58:25 localhost gdm-launch-environment]: pam_unix(gdm-launch-environment:session): session opened for user gdm by (uid=0)
May 31 00:58:27 localhost polkitd[656]: Registered Authentication Agent for unix-session:c1 (system bus name :1.55 [gnome-shell --mode=gdm], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 00:58:39 localhost gdm-password]: pam_unix(gdm-password:session): session opened for user jbc by (unknown)(uid=0)
May 31 00:58:40 localhost gdm-launch-environment]: pam_unix(gdm-launch-environment:session): session closed for user gdm
May 31 00:58:40 localhost polkitd[656]: Unregistered Authentication Agent for unix-session:c1 (system bus name :1.55, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
May 31 00:58:40 localhost polkitd[656]: Registered Authentication Agent for unix-session:2 (system bus name :1.69 [/usr/libexec/xfce-polkit], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 00:59:30 localhost sudo:     jbc : user NOT in sudoers ; TTY=pts/0 ; PWD=/home/jbc ; USER=root ; COMMAND=/bin/yum remove --purge chromium
May 31 00:59:42 localhost su: pam_unix(su-l:session): session opened for user root by jbc(uid=1000)
May 31 01:15:18 localhost polkitd[656]: Registered Authentication Agent for unix-process:4582:105315 (system bus name :1.86 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 12:58:19 localhost polkitd[659]: Loading rules from directory /etc/polkit-1/rules.d
May 31 12:58:19 localhost polkitd[659]: Loading rules from directory /usr/share/polkit-1/rules.d
May 31 12:58:19 localhost polkitd[659]: Finished loading, compiling and executing 4 rules
May 31 12:58:19 localhost polkitd[659]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
May 31 12:58:29 localhost sshd[1139]: Server listening on 0.0.0.0 port 22.
May 31 12:58:29 localhost sshd[1139]: Server listening on :: port 22.
May 31 12:58:52 localhost login: pam_unix(login:session): session opened for user jbc by LOGIN(uid=0)
May 31 12:58:52 localhost login: LOGIN ON tty1 BY jbc
May 31 13:02:01 localhost polkitd[659]: Registered Authentication Agent for unix-process:2581:22909 (system bus name :1.34 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 13:02:04 localhost polkitd[659]: Operator of unix-process:2581:22909 successfully authenticated as unix-user:root to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.35 [init 5] (owned by unix-user:jbc)
May 31 13:02:05 localhost polkitd[659]: Unregistered Authentication Agent for unix-process:2581:22909 (system bus name :1.34, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
May 31 13:02:05 localhost login: pam_unix(login:session): session closed for user jbc
May 31 13:02:06 localhost gdm-launch-environment]: pam_unix(gdm-launch-environment:session): session opened for user gdm by (uid=0)
May 31 13:02:09 localhost polkitd[659]: Registered Authentication Agent for unix-session:c1 (system bus name :1.64 [gnome-shell --mode=gdm], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 13:02:15 localhost gdm-password]: pam_unix(gdm-password:session): session opened for user jbc by (unknown)(uid=0)
May 31 13:02:16 localhost gdm-launch-environment]: pam_unix(gdm-launch-environment:session): session closed for user gdm
May 31 13:02:16 localhost polkitd[659]: Unregistered Authentication Agent for unix-session:c1 (system bus name :1.64, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
May 31 13:02:17 localhost polkitd[659]: Registered Authentication Agent for unix-session:4 (system bus name :1.78 [/usr/libexec/xfce-polkit], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 13:02:33 localhost su: pam_unix(su-l:session): session opened for user root by jbc(uid=1000)
May 31 13:03:18 localhost polkitd[659]: Registered Authentication Agent for unix-process:4348:30623 (system bus name :1.87 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 13:03:18 localhost polkitd[659]: Unregistered Authentication Agent for unix-process:4348:30623 (system bus name :1.87, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

또한 /var/log/secureSSH 관련:

[root@localhost ~]# cat /var/log/secure | grep "May 31" | grep ssh
May 31 00:58:03 localhost sshd[1141]: Server listening on 0.0.0.0 port 22.
May 31 00:58:03 localhost sshd[1141]: Server listening on :: port 22.
May 31 12:58:29 localhost sshd[1139]: Server listening on 0.0.0.0 port 22.
May 31 12:58:29 localhost sshd[1139]: Server listening on :: port 22.

답변1

당신은 말했다:

다른 호스트 포트(임의의 높은 포트 번호)를 사용합니다.

하지만 귀하의 로그에는 다음이 표시됩니다.

0.0.0.0 포트 22에서 수신 대기하는 서버입니다.

로그인을 시도할 때CentOS상자에서 다음과 같은 응답을 받습니다.

OpenSSH_7.4p1데비안-10, OpenSSL 1.0.2k 2017년 1월 26일

그것이 전화에 응답하는 Ubuntu 상자입니다.

/etc/ssh/sshd_config.conf를 포함했다면 훨씬 더 분명했을 것입니다. 거기의 '포트'설정~ 해야 하다전달을 위해 구성한 높은 포트와 일치하십시오.

답변2

키 인증이 실패한 것 같습니다(설정했습니까?). /etc/ssh/sshd_config에 다음 줄이 누락되었을 수 있습니다.

PasswordAuthentication yes

자세한 내용을 보려면 CentOS VM의 /etc/ssh/sshd_config 파일을 포함할 수도 있습니다.

관련 정보