ssh 更换端口

  1. 修改ssh 端口

netstat -anp | grep -i sshd

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      20981/sshd

2)

重新设置 SSH 的监听端口,只需修改 /etc/ssh/sshd_config 中的 Port 即可,如:

#Port 22 这一行修改为

 

Port 22522

3)如果服务器启用了 SELinux,则还需进行额外配置。若SELinux未打开(输出no),直接跳转步骤4.

首先,确认 SELinux 是否启用:

sestatus 2> /dev/null | grep -E -q 'SELinux status:\s+enabled' && echo yes || echo no

输出 yes 即表示启用了 SELinux,那么就需要再对 SELinux 进行配置:

semanage port -a -t ssh_port_t -p tcp 22522

4)重启sshd服务   systemctl restart sshd.service

5)查看SSH服务状态及暴力端口

[root@localhost ~]# systemctl status sshd.service

● sshd.service - OpenSSH server daemon

   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)

   Active: active (running) since 三 2019-01-23 17:11:24 CST; 2s ago

     Docs: man:sshd(8)

           man:sshd_config(5)

 Main PID: 24291 (sshd)

   CGroup: /system.slice/sshd.service

           └─24291 /usr/sbin/sshd -D

 

1月 23 17:11:24 localhost.localdomain systemd[1]: Stopped OpenSSH server daemon.

1月 23 17:11:24 localhost.localdomain systemd[1]: Started OpenSSH server daemon.

1月 23 17:11:24 localhost.localdomain sshd[24291]: Server listening on 0.0.0.0 port 22522.

1月 23 17:11:24 localhost.localdomain sshd[24291]: Server listening on :: port 22522.

[root@localhost ~]#

[root@localhost ~]# netstat -anp | grep -i sshd

tcp        0      0 0.0.0.0:22522           0.0.0.0:*               LISTEN      24291/sshd

  1. ssh 访问

ssh -p 22522 abcd@192.168.1.32

  1. scp 访问

scp -P 22522 zqd root@192.168.1.32:/root

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值