1、登錄服務器,打開sshd_config文件
# vim /etc/ssh/sshd_config
2、找到#Port 22,默認是注釋掉的,先把前面的#號去掉,再插入一行設置成你想要的端口號,注意不要跟現有端口號重復
# 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 change a
# default value.
Port 22
Port 26580
3、保存后退出,執行重啟命令
# /etc/init.d/sshd restart
4、新開一個終端窗口測試23456端口是否可以正常連接服務器,如果成功則將Port 22刪除,之所以先設置成兩個端口,測試成功后再關閉一個端口,是為了方式在修改conf的過程中,萬一出現掉線、斷網、誤操作等未知情況時候,還能通過另外一個端口連接上去調試以免發生連接不上必須派人去機房,導致問題更加復雜麻煩。