Debian 10 "Buster"에서 연결할 수 없습니다 sshd
. 연결할 때 다음 오류가 발생합니다.
$ ssh -p 2222 [email protected]
ssh_exchange_identification: read: Connection reset by peer
이러한 서비스를 확인하면 다음 오류가 발생합니다.
● sshd.service - OpenBSD Secure Shell server
Loaded: loaded (/etc/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-10-22 18:10:51 -03; 13min ago
Process: 559 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 606 (sshd)
Tasks: 1 (limit: 2304)
Memory: 2.3M
CGroup: /system.slice/sshd.service
└─606 /usr/sbin/sshd -D
Oct 22 18:10:50 ffurtpc systemd[1]: Starting OpenBSD Secure Shell server...
Oct 22 18:10:51 ffurtpc sshd[606]: Server listening on 0.0.0.0 port 22.
Oct 22 18:10:51 ffurtpc sshd[606]: error: Bind to port 22 on :: failed: Address already in use.
Oct 22 18:10:51 ffurtpc systemd[1]: Started OpenBSD Secure Shell server.
Oct 22 18:14:26 ffurtpc sshd[1514]: Connection closed by authenticating user friedrich 192.168.12.73 port 49880 [preauth]
Oct 22 18:23:45 ffurtpc sshd[1583]: fatal: Missing privilege separation directory: /run/sshd
xinetd
OpenBSD Secure Shell 서버가 다음과 같이 포트 22에서 계속 수신 대기하는 동안 패키지를 사용하여 포트 2222로 설정하여 관리해 보았습니다 .
● xinetd.service - LSB: Starts or stops the xinetd daemon.
Loaded: loaded (/etc/init.d/xinetd; generated)
Active: active (running) since Tue 2019-10-22 18:10:55 -03; 15min ago
Docs: man:systemd-sysv-generator(8)
Process: 722 ExecStart=/etc/init.d/xinetd start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 2304)
Memory: 4.5M
CGroup: /system.slice/xinetd.service
└─755 /usr/sbin/xinetd -pidfile /run/xinetd.pid -stayalive -inetd_compat -inetd_ipv6
Oct 22 18:10:56 ffurtpc xinetd[755]: Reading included configuration file: /etc/xinetd.d/echo-udp [file=/etc/xinetd.d/echo-udp] [line=26]
Oct 22 18:10:56 ffurtpc xinetd[755]: Reading included configuration file: /etc/xinetd.d/servers [file=/etc/xinetd.d/servers] [line=14]
Oct 22 18:10:56 ffurtpc xinetd[755]: Reading included configuration file: /etc/xinetd.d/services [file=/etc/xinetd.d/services] [line=13]
Oct 22 18:10:56 ffurtpc xinetd[755]: Reading included configuration file: /etc/xinetd.d/sshd [file=/etc/xinetd.d/sshd] [line=13]
Oct 22 18:10:56 ffurtpc xinetd[755]: Reading included configuration file: /etc/xinetd.d/time [file=/etc/xinetd.d/time] [line=16]
Oct 22 18:10:56 ffurtpc xinetd[755]: Reading included configuration file: /etc/xinetd.d/time-udp [file=/etc/xinetd.d/time-udp] [line=28]
Oct 22 18:10:56 ffurtpc xinetd[755]: 2.3.15.3 started with libwrap loadavg labeled-networking options compiled in.
Oct 22 18:10:56 ffurtpc xinetd[755]: Started working: 1 available service
Oct 22 18:14:22 ffurtpc sshd[1512]: Connection closed by authenticating user friedrich 192.168.12.73 port 35954 [preauth]
Oct 22 18:23:43 ffurtpc sshd[1582]: fatal: Missing privilege separation directory: /run/sshd
어떤 아이디어가 있나요?
답변1
sshd
여기에도 비슷한 오류가 있었습니다. 시작 시 디렉터리를 생성할 수 없는 것처럼 보였으 /run/sshd
므로 여기서는 다음과 같은 스크립트를 통해 수행했습니다.
다음에서 sshddir
스크립트를 작성하십시오 /etc/init.d/
.
#!/bin/sh
### BEGIN INIT INFO
# Provides: sshddir
# Required-Start: $all
# Required-Stop: $network
# Should-Start: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Sshd /run/sshd Directory
# Description: Intended to create /run/sshd directory for Sshd.
### END INIT INFO
mkdir -p /run/sshd
chmod -R 755 /run/sshd
$ sudo chmod 755 /etc/init.d/sshddir
$ sudo update-rc.d sshddir defaults
이렇게 하면 재부팅하고 액세스할 수 있습니다.
답변2
다음 내용으로 sshddir.service
파일을 생성하세요 /etc/system/systemd/
.
[Unit]
Description=Run Sshd Directory Creator
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
ExecStart=/usr/bin/sshddir
ExecReload=/usr/bin/sshddir
Restart=always
RestartPreventExitStatus=255
Type=forking
[Install]
WantedBy=multi-user.target
Alias=sshddir.service
그 다음에:
2a-$ sudo systemctl daemon-reload
2b-$ sudo systemctl enable sshddir
하지만 호스팅된 파일을 먼저 삭제해야 합니다 SysVinit
.
1a-$ update-rc.d sshddir disable
1b-$ update-rc.d sshddir remove
그런 다음 기기를 다시 시작하세요.
systemd
시작 시 폴더가 삭제되어 오류가 발생한 것 같습니다 ./run/sshd