- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
安裝SSH
yum install ssh
啟動SSH
service sshd start
設置開機運行
chkconfig sshd on
SSH相關配置文件的修改
首先修改SSH的配置文件。如下:
[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 ← 修改后變為此狀態,禁?空密碼進行登錄
然后保存并退出。(vi保存退出的命令為ZZ)
因為我們只想讓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連接請求
netstat -tunlp 查看正在運行的端口號!vim /etc/ssh/sshd_config這個文件,這里把#Port 22這個字段前面的#去掉,再把22改成自己要設的端口就行了,然后重啟ssh服務。/etc/init.d/sshd restart 假如要限制SSH登陸的IP,那么可以如下做:修改/etc/hosts.deny,在其中加入sshd:ALL修改:/etc/hosts.allow,在其中進行如下設置:sshd:192.168.0.24這樣就可以限制只有192.168.0.241的IP通過SSH登陸上LINUX機器了
SSH遠程連接配置
1.配置IP
#setup
選擇 NetWork configuration
選擇 Device configuration
選擇 eth0
Use DHCP [*] 改 為 [ ] 用空格鍵將*去除
Static IP 輸入 192.168.1.112
Netmask 輸入 255.255.255.0
Default gateway IP 輸入 192.168.1.1
Primary DNS Server 輸入 192.168.1.1
2.改SSH端口
vim /etc/ssh/sshd_config
#Port 22
去#注釋 改 22 為 2200(2000以上)
3.重啟SSH
/etc/init.d/sshd restart
4.重啟網絡
service network restart
或
/etc/init.d/network restart
5.查看端口
netstat -lnp|more
6.關防火墻
/etc/init.d/iptables stop
啟動SSH
/etc/init.d/sshd start
至此SSH已經可以連接了
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP