新聞中心
一、明文傳輸與加密傳輸
明文傳輸:當(dāng)我們的數(shù)據(jù)包在網(wǎng)絡(luò)上傳輸?shù)臅r(shí)候,以數(shù)據(jù)包的原始格式進(jìn)行傳輸,別人很容易截獲我們的數(shù)據(jù)包,得到我們的信息。

加密傳輸:當(dāng)兩個(gè)主機(jī)之間傳輸信息或者是A主機(jī)遠(yuǎn)程控制B主機(jī)的時(shí)候,在兩個(gè)主機(jī)傳輸數(shù)據(jù)包之前,加密過(guò)之后才通過(guò)網(wǎng)絡(luò)傳輸過(guò)去。因此,就算有人截獲了傳輸?shù)臄?shù)據(jù)包,也不知道傳輸?shù)膬?nèi)容。
二、SSH(Secure Shell)簡(jiǎn)介
SSH是建立在傳輸層和應(yīng)用層上面的一種安全的傳輸協(xié)議。SSH目前較為可靠,專為遠(yuǎn)程登錄和其他網(wǎng)絡(luò)提供的安全協(xié)議。在主機(jī)遠(yuǎn)程登錄的過(guò)程中有兩種認(rèn)證方式:
基于口令認(rèn)證:只要你知道自己帳號(hào)和口令,就可以登錄到遠(yuǎn)程主機(jī)。所有傳輸?shù)臄?shù)據(jù)都會(huì)被加密,但是不能保證你正在連接的服務(wù)器就是你想連接的服務(wù)器??赡軙?huì)有別的服務(wù)器在冒充真正的服務(wù)器,也就是受到“中間人”這種方式的攻擊。
基于秘鑰認(rèn)證:需要依靠秘鑰,也就是你必須為自己創(chuàng)建一對(duì)秘鑰,并把公用的秘鑰放到你要訪問(wèn)的服務(wù)器上,客戶端軟件就會(huì)向服務(wù)器發(fā)出請(qǐng)求,請(qǐng)求用你的秘鑰進(jìn)行安全驗(yàn)證。服務(wù)器收到請(qǐng)求之后,現(xiàn)在該服務(wù)器你的主目錄下尋找你的公用秘鑰,然后吧它和你發(fā)送過(guò)來(lái)的公用秘鑰進(jìn)行比較。弱兩個(gè)秘鑰一致服務(wù)器就用公用秘鑰加密“質(zhì)詢”并把它發(fā)送給客戶端軟件,客戶端軟件收到質(zhì)詢之后,就可以用你的私人秘鑰進(jìn)行解密再把它發(fā)送給服務(wù)器。
用這種方式,你必須要知道自己的秘鑰口令。但是與第一種級(jí)別相比,地為主不需要再網(wǎng)絡(luò)上傳輸口令
第二種級(jí)別不僅加密所有傳送的數(shù)據(jù),而且“中間人”這種攻擊方式也是不可能的(因?yàn)樗麤](méi)有你的私人密匙)。但是整個(gè)登錄的過(guò)程可能需要10秒。
三、啟動(dòng)SSH服務(wù)
3.1 注意:
CentOS 7.1安裝完之后默認(rèn)已經(jīng)啟動(dòng)了ssh服務(wù)我們可以通過(guò)以下命令來(lái)查看ssh服務(wù)是否啟動(dòng)。
3.2查看22端口是否開(kāi)放
#netstat -tnl
3.3查看ssh服務(wù)是否啟動(dòng)
#systemctl status sshd.service
四、SSH客戶端連接服務(wù)器(口令認(rèn)證)
4.1 直接連接到對(duì)方的主機(jī),這樣登錄服務(wù)器的默認(rèn)用戶
$ssh 192.168.142.84
[admin@localhost ~]$ ssh 192.168.142.84
[email protected]’s password:
Last login: Sat Jun 27 10:16:21 2015 from 10.66.85.46
Hello world
Welcome to this Linux ! 2015年 06月 27日 星期六 10:54:54 CST$exit 退出遠(yuǎn)程登錄
4.2 使用賬號(hào)登錄對(duì)方主機(jī)nii用戶
[admin@localhost ~]$ ssh [email protected]
[email protected]'s password: Last login: Fri Jun 26 14:48:03 2015 from 192.168.142.35 Hello world[nii@localhost ~]$ exit
登出
Connection to 192.168.142.84 closed.
五、SSH客戶端連接服務(wù)器(秘鑰認(rèn)證)
這種認(rèn)證方式是比較安全的。
秘鑰認(rèn)證步驟:
-
生成公鑰和私鑰,生成的秘鑰默認(rèn)在/root/.ssh/文件夾里面
[root@localhost admin]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
7e:fa:8c:c4:a5:0d:e0:db:8e:87:25:15:4a:d2:9b:0b [email protected]
The key’s randomart image is:
+–[ RSA 2048]—-+
| . |
| . o . |
| o.+ . |
| E.+.. |
| ..oS . |
| o=.= |
| .+* o |
| .+.= |
| ..+.o |
+—————–+ -
把生成的公鑰發(fā)送到對(duì)方的主機(jī)上去,用ssh-copy-id命令,自動(dòng)保存在對(duì)方主機(jī)的/root/.ssh/authorized_keys 文件中去
[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keys
[email protected]’s password:
Hello worldNumber of key(s) added: 1
Now try logging into the machine, with: “ssh >’[email protected]’”
and check to make sure that only the key(s) you wanted were added.[root@localhost ~]# ssh 192.168.142.84 登錄不需要密碼了
Last login: Sat Jun 27 10:01:07 2015 from 192.168.142.191
Hello world
網(wǎng)站題目:CentOS7.1下SSH遠(yuǎn)程登錄服務(wù)器詳解
鏈接地址:http://m.fisionsoft.com.cn/article/djjeddc.html


咨詢
建站咨詢
