i. 在配置文件/etc/ssh/sshd_config文件中修改

17 Port 5522
18 #AddressFamily any
19 #ListenAddress 0.0.0.0
20 #ListenAddress ::

ii. 然后重启sshd

[root@localhost ~]# systemctl restart sshd

iii. 如果自定义端口,重启sshd出现如下报错:

[root@localhost ~]# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.

查看详细如下:

[root@localhost ~]# journalctl -xe
-- 
-- Unit sshd.service has failed.
-- 
-- The result is failed.
Jul 19 22:39:08 localhost.localdomain systemd[1]: Unit sshd.service entered failed state.
Jul 19 22:39:08 localhost.localdomain systemd[1]: sshd.service failed.
Jul 19 22:39:08 localhost.localdomain polkitd[695]: Unregistered Authentication Agent for unix-process:3128:1153611 
Jul 19 22:39:38 localhost.localdomain polkitd[695]: Registered Authentication Agent for unix-process:3140:1156691 (s
Jul 19 22:39:38 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
-- Subject: Unit sshd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit sshd.service has begun starting up.
Jul 19 22:39:38 localhost.localdomain sshd[3146]: error: Bind to port 5522 on 0.0.0.0 failed: Permission denied.
Jul 19 22:39:38 localhost.localdomain sshd[3146]: error: Bind to port 5522 on :: failed: Permission denied.
Jul 19 22:39:38 localhost.localdomain sshd[3146]: fatal: Cannot bind any address.
Jul 19 22:39:38 localhost.localdomain systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
Jul 19 22:39:38 localhost.localdomain systemd[1]: Failed to start OpenSSH server daemon.
-- Subject: Unit sshd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit sshd.service has failed.
-- 
-- The result is failed.
Jul 19 22:39:38 localhost.localdomain systemd[1]: Unit sshd.service entered failed state.
Jul 19 22:39:38 localhost.localdomain systemd[1]: sshd.service failed.
Jul 19 22:39:38 localhost.localdomain polkitd[695]: Unregistered Authentication Agent for unix-process:3140:1156691 
View Code

相关文章:

  • 2021-09-08
  • 2021-06-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2022-02-07
  • 2021-11-18
  • 2022-12-23
  • 2022-02-26
  • 2022-02-07
相关资源
相似解决方案