AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 672680
Accepted
ndemou
ndemou
Asked: 2015-03-04 02:54:51 +0800 CST2015-03-04 02:54:51 +0800 CST 2015-03-04 02:54:51 +0800 CST

仅当使用 bash -x /etc/init.d/sshd restart 重新启动时,sshd 才会绑定到低编号端口

  • 772

我在 /etc/ssh/sshd_config 中添加了行“Port 110”,就在现有行“Port 22”的下方,然后/etc/init.d/sshd restart期望看到 sshd 在两个端口(22 和 110)上进行监听。然而 netstat -anp 显示 sshd 只监听默认端口(22)。

后来我尝试bash -x /etc/init.d/sshd restart了,惊讶地看到 sshd 立即绑定到 110 端口!!!再次发布第二/etc/init.d/sshd restart次忽略了我的更改。重新启动也忽略了我的更改,所以我被卡住并且完全困惑。

更新这种奇怪的行为只出现在低端口(<1024)

这是在 CentOS 6 服务器上。


细节

这是我对 /etc/ssh/sshd_config 的修改:

grep ^Port /etc/ssh/sshd_config
Port 22
Port 110

netstat 之后的输出bash -x /etc/init.d/sshd restart

netstat -anp | grep -i listen|grep sshd|grep -v :::
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      7031/sshd           
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      7031/sshd     

netstat 之后的输出/etc/init.d/sshd restart

netstat -anp | grep -i listen|grep sshd|grep -v :::
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      8962/sshd  

说服 sshd 绑定到端口 110 的另一种方法是在调试模式下运行它/usr/sbin/sshd -de (注意这些listening on port 22,110行,但我也通过连接到两个端口进行了测试):

/usr/sbin/sshd -de
debug1: sshd version OpenSSH_5.3p1
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-de'
Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 22 on 0.0.0.0.
Server listening on 0.0.0.0 port 22.
debug1: Bind to port 22 on ::.
Server listening on :: port 22.
debug1: Bind to port 110 on 0.0.0.0.
Server listening on 0.0.0.0 port 110.
debug1: Bind to port 110 on ::.
Server listening on :: port 110.
centos
  • 1 1 个回答
  • 523 Views

1 个回答

  • Voted
  1. Best Answer
    user9517
    2015-03-04T23:18:39+08:002015-03-04T23:18:39+08:00

    SELinux 系统正在限制 1024 以下端口的端口绑定

    semanage port -l | grep ssh
    ssh_port_t                     tcp      22
    

    您可以添加另一个端口

    semanage port -a -t ssh_port_t -p tcp 110
    

    那将解决您的直接问题。

    • 6

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve