(Ubuntu 22.10) SSH default port not changing

SSHd now uses socket-based activation Ubuntu 22.10 or later. 

The are unused, now that I read the comments in full I found:/etc/ssh/sshd_config

# Port and ListenAddress options are not used when sshd is socket-activated,
# which is now the default in Ubuntu. See sshd_config(5) and
# /usr/share/doc/openssh-server/README.Debian.gz for details.

 So there are two options for you to change from default port:

  • Turning off this change and reverting to how SSHd worked prior to this update

    • systemctl disable --now ssh.socket
    • systemctl enable --now ssh.service
    • Then the /etc/ssh/sshd_config works again with Ports and Addresses setting
  • OR Listening socket stream update

    • mkdir -p /etc/systemd/system/ssh.socket.d

    • cat >/etc/systemd/system/ssh.socket.d/listen.conf <<EOF

      ​​​​​​​[Socket] 
      ListenStream=12345
      EOF
    • sudo systemctl daemon-reload

    • sudo systemctl restart ssh

It should then state it's started listening on the new port: sudo systemctl status ssh

Server listening on 0.0.0.0 port 12345.
Server listening on :: port 12345

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值