【问题标题】:Why "service sshd start" command can not return to command prompt?为什么“service sshd start”命令无法返回命令提示符?
【发布时间】:2017-11-11 01:57:01
【问题描述】:

我正在安装一个新的 CentOS7,它的 sshd 服务运行良好。然后我下载了openssh7.5p1的源码,编译安装到默认目录“/usr/local/sbin/sshd”。我想用它来替换系统的sshd。

  1. 我修改文件“/usr/lib/systemd/system/sshd.service”,更改以下行: old: ExecStart=/usr/sbin/sshd $OPTIONS new: ExecStart=/usr/local/sbin/sshd $OPTIONS

  2. 之后,输入命令“service sshd start”,命令无法返回,似乎挂了。如下所示: [root@localhost ~]# service sshd start Redirecting to /bin/systemctl start sshd.service

  3. 我按下 Ctl+C 来终止命令。然后使用命令“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. 我尝试手动启动 sshd,它工作正常,sshd 启动成功(没有任何警告消息)并且命令立即返回。命令如下: [root@localhost ~]# /usr/local/sbin/sshd -f /etc/ssh/sshd_config

感谢任何帮助。如果您想了解更多信息,请告诉我。谢谢。

【问题讨论】:

  • 日志中有什么内容?你能提供journalctl -u sshd的输出吗?

标签: linux service centos7 systemd sshd


【解决方案1】:

在你的 .service 中修改 type 怎么样? 您是否尝试将其设置为空闲? 也许 systemd 等待接收来自 sshd 的消息并且似乎挂起..

【讨论】:

    猜你喜欢
    • 2021-05-29
    • 2011-01-08
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多