centos 安裝配置ssh

來源:互聯網
上載者:User

標籤:

安裝SSH
yum install ssh

啟動SSH
service sshd start

設定開機運行
chkconfig sshd on

相關設定檔修改
[root@sample ~]# vi /etc/ssh/sshd_config  ← 用vi開啟SSH的設定檔
 

#Protocol 2,1 ← 找到此行將行頭“#”刪除,再將行末的“,1”刪除,只允許SSH2方式的串連
 ↓
Protocol 2 ← 修改後變為此狀態,僅使用SSH2

#ServerKeyBits 768 ← 找到這一行,將行首的“#”去掉,並將768改為1024
 ↓
ServerKeyBits 1024 ← 修改後變為此狀態,將ServerKey強度改為1024位元

#PermitRootLogin yes  ← 找到這一行,將行首的“#”去掉,並將yes改為no
 ↓
PermitRootLogin no  ← 修改後變為此狀態,不允許用root進行登入

#PasswordAuthentication yes ← 找到這一行,將yes改為no
 ↓
PasswordAuthentication no ← 修改後變為此狀態,不允許密碼方式的登入

#PermitEmptyPasswords no  ← 找到此行將行頭的“#”刪除,不允許空密碼登入
 ↓
PermitEmptyPasswords no  ← 修改後變為此狀態,禁止空密碼進行登入

 

因為我們只想讓SSH服務為管理系統提供方便,所以在不通過外網遠端管理系統的情況下,只允許內網用戶端通過SSH登入到伺服器,以最大限度減少不安全因素。設定方法如下:
[root@sample ~]# vi /etc/hosts.deny  ← 修改屏蔽規則,在文尾添加相應行


#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!

sshd: ALL  ← 添加這一行,屏蔽來自所有的SSH串連請求

[root@sample ~]# vi /etc/hosts.allow  ← 修改允許規則,在文尾添加相應行

#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#

sshd: 192.168.0.  ← 添加這一行,只允許來自內網的SSH串連請求

 注意:hosts.deny 和hosts.allow在簡單配置可以不修改,

如遇此兩個檔案唯讀,可以chmod提權

最後重啟動SSH啟動
# /etc/rc.d/init.d/sshd restart

centos 安裝配置ssh

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.