Linux设定ssh在port22及23两个端口监听
[root@www ~]# vim /etc/ssh/sshd_config
Port 22
Port 23 <==注意喔!要有两个 Port 的设定才行!

[root@www ~]# /etc/init.d/sshd restart
但是这一版的 CentOS 却将 SSH 规范 port 仅能启动于 22 而已,所以此时会出现一个 SELinux 的错误!
根据 setroubleshoot 的提示,我们必须要自行定义一个 SELinux 的规则放行模块才行!

  1. 于 /var/log/audit/audit.log 找出与 ssh 有关的 AVC 信息,并转为本地模块
    [root@www ~]# cat /var/log/audit/audit.log | grep AVC | grep ssh | audit2allow -m sshlocal > sshlocal.te <==扩展名要是 .te 才行
    [root@www ~]# grep sshd_t /var/log/audit/audit.log | audit2allow -M sshlocal <==sshlocal 就是刚刚建立的 .te 檔名

* IMPORTANT
To make this policy package active, execute:
semodule -i sshlocal.pp <==这个指令会编译出这个重要的 .pp 模块!

  1. 将这个模块加载系统的 SELinux 管理当中!
    [root@www ~]# semodule -i sshlocal.pp

  2. 再重新启动 sshd 并且观察埠口吧!
    [root@www ~]# /etc/init.d/sshd restart
    [root@www ~]# netstat -tlunp | grep ssh

非标准端口的连接方式
ssh -p 23 root@localhost