柚子快報激活碼778899分享:運維 SSH遠程管理
柚子快報激活碼778899分享:運維 SSH遠程管理
SSH遠程連接協(xié)議
SSH(Secure Shell)是一種安全通道協(xié)議,主要用來實現(xiàn)字符界面的遠程登錄、遠程 復制等功能。SSH 協(xié)議對通信雙方的數(shù)據(jù)傳輸進行了加密處理,其中包括用戶登錄時輸入的用戶口令,SSH 為建立在應用層和傳輸層基礎上的安全協(xié)議。對數(shù)據(jù)進行壓縮,加快傳輸速度。
優(yōu)點:
安全性: 數(shù)據(jù)傳輸是加密的,可以防止信息泄漏。 身份驗證:防止未經(jīng)授權的用戶訪問遠程系統(tǒng)。 遠程管理:可通過SSH協(xié)議登錄遠程服務器并執(zhí)行命令,無需直接物理訪問設備。 端口轉發(fā):SSH支持 端口轉發(fā)功能,可以安全地傳輸其他協(xié)議和應用程序。 傳輸速度: 數(shù)據(jù)傳輸是壓縮的,可以提高傳輸速度。
客戶端存放公鑰的位置
家目錄下/.ssh/know_host
連接方式
ssh ip地址
原理:
客戶端首先發(fā)起連接給服務器
服務器收到請求將自己的公鑰以及會話id發(fā)給客戶端
客戶端收到服務器的公鑰,以及會話id,會做一個運算
res=會話ID+客戶端的公鑰
再用服務器的公鑰進行加密傳給服務器
服務器收到后
先用都無端自己的私鑰解密
已知會話ID
res-id=客戶端的公鑰
服務名主程序配置文件opnessh-server/usr/sbin/sshd/etc/ssh/sshd_configopnessh-clients/usr/bin/ssh/etc/ssh/ssh_config
密鑰的存放文件
自己的 /etc/ssh
對面的
家目錄/,ssh/know_host
ssh 選項 IP -p 端口
ssh加密通訊原理
1.對稱加密
采用單鑰密碼系統(tǒng)的加密方法,同一個密鑰可以同時用作信息的加密和解密,這種加密方法稱為對稱加密,由于其速度快,對稱性加密通常在消息發(fā)送方需要加密大量數(shù)據(jù)時使用
特點
1、加密方和解密方使用同一個密鑰; 2、加密解密的速度比較快,適合數(shù)據(jù)比較長時的使用; 3、密鑰傳輸?shù)倪^程不安全,且容易被破解,密鑰管理也比較麻煩;
常用算法
DES、3DES、TDEA、Blowfish、RC2、RC4、RC5、IDEA、SKIPJACK等
優(yōu)點
1.算法公開 2.計算量小 3.加密速度快 4.加密效率高
缺點
在數(shù)據(jù)傳送前,發(fā)送方和接收方必須商定好秘鑰,然后使雙方都能保存好秘鑰其次如果一方的秘鑰被泄露,那么加密信息也就不安全了每對用戶每次使用對稱加密算法時,都需要使用其他人不知道的獨一秘鑰,這會使得收、發(fā)雙方所擁有的鑰匙數(shù)量巨大,密鑰管理成為雙方的負擔
2.非對稱加密
非對稱加密算法需要兩個密鑰:公開密鑰(publickey:簡稱公鑰)和私有密鑰(privatekey:簡稱私鑰)。公鑰與私鑰是一對,如果用公鑰對數(shù)據(jù)進行加密,只有用對應的私鑰才能解密。因為加密和解密使用的是兩個不同的密鑰,所以這種算法叫作非對稱加密算法
常用算法
RSA(RSA algorithm):目前使用最廣泛的算法DSA(Digital Signature Algorithm):數(shù)字簽名算法,和 RSA 不同的是 DSA僅能用于數(shù)字簽名,不能進行數(shù)據(jù)加密解密,其安全性和RSA相當,但其性能要比RSA快ECC(Elliptic curve cryptography,橢圓曲線加密算法)ECDSA:Elliptic Curve Digital Signature Algorithm,橢圓曲線簽名算法,是ECC和 DSA的結合,相比于RSA算法,ECC 可以使用更小的秘鑰,更高的效率,提供更高的安全保障
原理
客戶端向服務端發(fā)起連接請求
服務端收到請求后,將會話id和服務端的公鑰交給客戶端
客戶端接收后,將會話id和客戶端的公鑰進行異或運算得到回復信息Res(Res=會話id^客戶端公鑰)
客戶端再將Res用服務端的公鑰加密,得到密文U(U=Res+服務端的公鑰id),并將密文U交給服務端
服務端用服務端私鑰將密文U解密,得到回復信息Res
服務端將Res和會話id進行異或運算,得到客戶端的公鑰
[root@localhost ~]# vim /etc/ssh/sshd_config
#Port 22 #監(jiān)聽端口
#AddressFamily any #地址為任意網(wǎng)卡
#ListenAddress 0.0.0.0
#ListenAddress ::
#LoginGraceTime 2m #登陸時間為2分鐘
#PermitRootLogin yes #是否允許root用戶登錄
#StrictModes yes
#MaxAuthTries 6 #最大重試密碼次數(shù)為6
#MaxSessions 10
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no #禁止空密碼用戶登錄
PasswordAuthentication yes
#UseDNS no #禁止DNS反向解析,提高速率
[root@localhost ~]# ssh-keygen -t ecdsa #生成密鑰文件
Generating public/private ecdsa key pair.
Enter file in which to save the key (/root/.ssh/id_ecdsa): #密鑰存放位置
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): #密碼為空直接回車
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_ecdsa.
Your public key has been saved in /root/.ssh/id_ecdsa.pub.
The key fingerprint is:
SHA256:cjM0TYPcoopfBaqUoY3qJPozDpbKHlXkDERj5+Da8e0 root@localhost.localdomain
The key's randomart image is:
+---[ECDSA 256]---+
| oB o . oo |
| + X . +o.. |
| + = * oo.. |
|o * = o... |
|.o = o.oS |
|o.= . oo o |
|*+ . . E |
|=o+ . |
|o=oo |
+----[SHA256]-----+
[root@localhost ~]# cd .ssh
[root@localhost .ssh]# ls
id_ecdsa id_ecdsa.pub #公鑰和私鑰
[root@localhost .ssh]# ssh-copy-id -i id_ecdsa.pub 192.168.118.30
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_ecdsa.pub"
/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
root@192.168.118.30's password: #服務端密碼
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.118.30'"
and check to make sure that only the key(s) you wanted were added.
[root@localhost .ssh]# ssh 192.168.118.30
Last login: Mon Apr 29 13:50:39 2024 from 192.168.118.20
[root@localhost ~]#
柚子快報激活碼778899分享:運維 SSH遠程管理
文章鏈接
本文內(nèi)容根據(jù)網(wǎng)絡資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。
轉載請注明,如有侵權,聯(lián)系刪除。