You are currently viewing CentOS7 架設SSH
  • Post author:
  • Post last modified:29 6 月, 2022

Step1 : 下載ssh

$ sudo yum install openssh* 

Step2 : 設定 ssh config

$  sudo vi /etc/ssh/sshd_config 

##  1. 修改登入 port ( 預設為22 )

port 55442

##  2. 限定登入者 

將下列設定自行新增到檔案最後

AllowUsers id1 id2

## 3. 註解拿掉

PermitEmptyPasswords no
PasswordAuthentication yes

## 4. 限制root帳號登入

PermitRootLogin no

 

Step3 : 啟動ssh / 設定開機時自動啟動

重新啟動 ssh

$  sudo systemctl restart sshd.service    

設定開機時自動啟動ssh

$ sudo systemctl enable sshd.service    

Step4 : Firewall 防火牆設定

開啟防火牆

$   sudo firewall-cmd –permanent –zone=public –add-port=55442/tcp   

re-load 防火牆

$  sudo firewall-cmd –reload  

以上ssh就已經安裝設定完成

可以輸入 netstat -ant 看看剛剛的55442 PORT有沒有加入監控中.