美文网首页
centos上ssh服务相关命令

centos上ssh服务相关命令

作者: 黄瓜熟了 | 来源:发表于2020-09-06 11:26 被阅读0次

(一)

rpm -qa | grep ssh #查看当前系统是否安装了SSH软件包

systemctl status sshd.service    #查看SSH服务状态

#Active: active (running) 重点关注

systemctl start sshd.service       #开启SSH服务

systemctl stop sshd.service       # 关闭SSH服务

systemctl restart sshd.service   #重启SSH服务 

修改SSH服务m默认端口号(默认:22)

vi   /etc/ssh/sshd_config 

找到#port=22 改为port=222 删掉#符号

再次启动SSH服务后若出现如下提示,此时修改SSH默认端口不成功

Job for ssh.service failed because the control process exited with error codesee systemctl status ssh.service and journalctl -xe for details.

(二)

先查看SELinux开放给ssh使用的端口

semanage port -i | grep ssh   

ssh_port_t     tcp     22  #系统输出

#若说输出 -bash: semanage: command not found  则需要输入命令安装 yum -y install policycoreutils-python.x86_64 

所以,SELinux没有给ssh开放222端口,要添加该端口

semanage port -a -t ssh_port_t -p tcp 222

semanage port -l | grep ssh  #再次查看

ssh_port_t     tcp        222, 22

再重启ssh服务

如果防火墙服务开启,还要查看防火墙是否开启了开启端口并放开相对应端口(我这个防火墙关闭了)

仿照实验:CentOS7增加或修改SSH端口号

相关文章

网友评论

      本文标题:centos上ssh服务相关命令

      本文链接:https://www.haomeiwen.com/subject/vstcektx.html