在CentOS中設(shè)置SSH連接時,如何限制SSH連接的IP地址? centos允許ssh登錄
Twitter推特優(yōu)選跨境問答2025-04-279871
在CentOS中設(shè)置SSH連接時,限制SSH連接的IP地址可以通過編輯sshd_config
文件實(shí)現(xiàn)。以下是具體步驟:
- 打開終端,使用文本編輯器打開
/etc/ssh/sshd_config
文件??梢允褂靡韵旅睿?/li>
sudo vi /etc/ssh/sshd_config
- 在打開的文件中,找到或添加以下行:
# Force command-line authentication to only allow the local user and password
ForceCommand internal-password
保存并關(guān)閉文件。
重新啟動SSH服務(wù)以使更改生效:
sudo systemctl restart sshd
這樣,SSH連接將只允許本地用戶通過密碼進(jìn)行身份驗(yàn)證,從而限制了SSH連接的IP地址。
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。