修改 SSH 默认端口可以通过修改某个配置文件实现么
移民生活北美论坛 -> 生活互助

#1: 作者: 爱尔维修时间: 2017-3-16 04:30

按照这个文章:

lecturesnippets.com/le...7-minimal/


需要用到 semanage



但是, SELINUX 不工作的时候, semanage 也无用啊?


总是出错

ValueError: SELinux policy is not managed or store cannot be accessed.

例如某些 ISP 的默认虚拟机映像是不允许更新 KERNEL 的。

怎么办?

#2: 作者: Piglet时间: 2017-3-16 09:12

狗一下就有结果了吧,sshd_conf

#3: 作者: A70Plus时间: 2017-3-16 09:14

sshd的设置文件,把里面的22改为你要的。

如果有开SELinux,要用工具告诉它。

#4: 作者: 爱尔维修时间: 2017-3-16 10:55

Piglet 写道:
狗一下就有结果了吧,sshd_conf


open the /etc/ssh/sshd_conf file by typing: vi /etc/ssh/sshd_config


发帖的时候已经改了这个,只有一半用, 如果 SELINUX 被核心禁止,

semanage port -a -t ssh_port_t -p tcp 9999

还是会出错。
ValueError: SELinux policy is not managed or store cannot be accessed.


当然, yum -y install policycoreutils-python 已经执行安装了。

也许还有一个列表需要改, 也就是 SELINUX 用来对照 SSHD 原始端口的表



cat /etc/services |grep ssh
ssh 22/tcp # The Secure Shell (SSH) Protocol
ssh 22/udp # The Secure Shell (SSH) Protocol
x11-ssh-offset 6010/tcp # SSH X11 forwarding offset
ssh 22/sctp # SSH
sshell 614/tcp # SSLshell
sshell 614/udp # SSLshell
netconf-ssh 830/tcp # NETCONF over SSH
netconf-ssh 830/udp # NETCONF over SSH
sdo-ssh 3897/tcp # Simple Distributed Objects over SSH
sdo-ssh 3897/udp # Simple Distributed Objects over SSH
snmpssh 5161/tcp # SNMP over SSH Transport Model
snmpssh-trap 5162/tcp # SNMP Notification over SSH Transport Model
tl1-ssh 6252/tcp # TL1 over SSH
tl1-ssh 6252/udp # TL1 over SSH
ssh-mgmt 17235/tcp # SSH Tectia Manager
ssh-mgmt 17235/udp # SSH Tectia Manager



semanage port -l | grep ssh
The output should now look like this:
ssh_port_t tcp 9999,22


怎样从根本改变 SSH 的端口使得

semanage port -l | grep ssh
只显示
ssh_port_t tcp 9999
呢?

也就是系统默认 SSH 是 9999 而不是 22,




也许应该想办法更新核心?

#5: 作者: 爱尔维修时间: 2017-3-19 17:32

run as the root user to remove the port from policy configuration.



semanage port -d -t ssh_port_t -p tcp 8888






to remove the port 8888 from policy configuration.


docs.fedoraproject.org...mbers.html




移民生活北美论坛 -> 生活互助


output generated using printer-friendly topic mod, 所有的时间均为 美国太平洋时间

1页,共1

Powered by phpBB 2.0.8
Content received from: 加西网 (温哥华门户), https://www.westca.com