首先 先作的就是 修改ssh的默認端口22html
須要修改文件centos
/etc/ssh/sshd_configssh
使用命令tcp
vi /etc/ssh/sshd_configide
[root@localhost ~]# vi /etc/ssh/sshd_config # $OpenBSD: sshd_config,v 1.90 2013/05/16 04:09:14 dtucker Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/local/bin:/usr/bin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value. # If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER # Port 48489 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: # The default requires explicit activation of protocol 1 #Protocol 2 # HostKey for protocol version 1 #HostKey /etc/ssh/ssh_host_key # HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key # Lifetime and size of ephemeral version 1 server key #KeyRegenerationInterval 1h #ServerKeyBits 1024 # Ciphers and keying #RekeyLimit default none # Logging # obsoletes QuietMode and FascistLogging #SyslogFacility AUTH SyslogFacility AUTHPRIV #LogLevel INFO # Authentication: #LoginGraceTime 2m #PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #RSAAuthentication yes #PubkeyAuthentication yes # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 # but this is overridden so installations will only check .ssh/authorized_keys AuthorizedKeysFile .ssh/authorized_keys #AuthorizedPrincipalsFile none #AuthorizedKeysCommand none
先作就完成了 端口的修改 而後就須要讓防火牆經過這個端口測試
具體操做 就是 按 I 鍵,進入插入編輯,找到Port前面的#去掉 ,改爲本身須要的端口號ui
centos 7 默認使用的 是 firewalld 因此先看看是否運行this
firewall-cmd --state.net
而後看下 先作默認經過的端口都有哪些3d
查看端口 規則
firewall-cmd --permanent --list-port
剛纔測試 添加了 端口 如今刪除這個端口 參數--permanent 是永久配置 機子重啓依然有效
刪除端口
firewall-cmd --permanent --remove-port=48489/tcp
添加端口 到防火牆例外
firewall-cmd --permanent --zone=public --add-port=48489/tcp
而後經過putty ssh鏈接軟件連接一下就行了~
firewalld 參考資料
http://blog.csdn.net/smstong/article/details/39317277