简体   繁体   English

为什么“ service sshd start”命令无法返回命令提示符?

[英]Why “service sshd start” command can not return to command prompt?

I'm install a new CentOS7, its sshd service works fine. 我正在安装新的CentOS7,它的sshd服务可以正常工作。 Then I download the source code of openssh7.5p1, build it and install it to the default directory "/usr/local/sbin/sshd". 然后,我下载openssh7.5p1的源代码,进行构建并将其安装到默认目录“ / usr / local / sbin / sshd”。 I want to use it to replace the system's sshd. 我想用它代替系统的sshd。

  1. I modify the file "/usr/lib/systemd/system/sshd.service", change following line: old: ExecStart=/usr/sbin/sshd $OPTIONS new: ExecStart=/usr/local/sbin/sshd $OPTIONS 我修改文件“ /usr/lib/systemd/system/sshd.service”,更改以下行: old: ExecStart=/usr/sbin/sshd $OPTIONS new: ExecStart=/usr/local/sbin/sshd $OPTIONS

  2. After that, type command "service sshd start", the command can not return and seems hang up. 之后,键入命令“ service sshd start”,该命令无法返回并且似乎挂断。 Looks as follows: [root@localhost ~]# service sshd start Redirecting to /bin/systemctl start sshd.service 看起来如下: [root@localhost ~]# service sshd start Redirecting to /bin/systemctl start sshd.service

  3. I press Ctl+C to terminate the command. 我按Ctl + C终止命令。 Then use command "netstat -ntlp" to find that the "sshd" already started, not sure why the "service sshd start" can not return to prompt. 然后使用命令“ netstat -ntlp”来发现“ sshd”已经启动,不确定为什么“ service sshd start”不能返回提示。 [root@localhost ~]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
    tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2443/dnsmasq
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 63144/sshd
    tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1043/cupsd
    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1815/master
    tcp6 0 0 :::111 :::* LISTEN 1/systemd
    tcp6 0 0 :::22 :::* LISTEN 63144/sshd
    tcp6 0 0 ::1:631 :::* LISTEN 1043/cupsd
    tcp6 0 0 ::1:25 :::* LISTEN 1815/master

  4. I try to start sshd manually, it works fine, the sshd started successfully(no any warning message) and the command return immediately. 我尝试手动启动sshd,它工作正常,sshd成功启​​动(没有任何警告消息),命令立即返回。 The command as follows: [root@localhost ~]# /usr/local/sbin/sshd -f /etc/ssh/sshd_config 命令如下: [root@localhost ~]# /usr/local/sbin/sshd -f /etc/ssh/sshd_config

Any help is appreciated. 任何帮助表示赞赏。 Let me know if you want to known more information. 如果您想了解更多信息,请告诉我。 Thanks. 谢谢。

How about tinkering With type in your .service ? 如何修改.service中的type呢? have you tried to set it to idle ? 您是否尝试将其设置为空闲? maybe systemd waits to receive a message from sshd and seems to hang.. 也许systemd等待接收来自sshd的消息并似乎挂起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM