Linux ssh命令:安全的遠程連接服務(wù)器
ssh命令的功能是用于安全的遠程連接服務(wù)器主機系統(tǒng),作為openssh套件中的客戶端連接工具,ssh命令可以讓我們輕松的基于ssh加密協(xié)議進行遠程主機訪問,從而實現(xiàn)對遠程服務(wù)器的管理工作。
語法格式: ssh [參數(shù)] 遠程主機
常用參數(shù):
-1 強制使用ssh協(xié)議版本1
-2 強制使用ssh協(xié)議版本2
-4 強制使用IPv4地址
-6 強制使用IPv6地址
-A 開啟認證代理連接轉(zhuǎn)發(fā)功能
-a 關(guān)閉認證代理連接轉(zhuǎn)發(fā)功能
-b<IP地址> 使用本機指定的地址作為對位連接的源IP地址
-C 請求壓縮所有數(shù)據(jù)
-F<配置文件> 指定ssh指令的配置文件,默認的配置文件為“/etc/ssh/ssh_config”
-f 后臺執(zhí)行ssh指令
-g 允許遠程主機連接本機的轉(zhuǎn)發(fā)端口
-i<身份文件> 指定身份文件(即私鑰文件)
-l<登錄名> 指定連接遠程服務(wù)器的登錄用戶名
-N 不執(zhí)行遠程指令
-o<選項> 指定配置選項
-p<端口> 指定遠程服務(wù)器上的端口
-q 靜默模式,所有的警告和診斷信息被禁止輸出
-X 開啟X11轉(zhuǎn)發(fā)功能
-x 關(guān)閉X11轉(zhuǎn)發(fā)功能
-y 開啟信任X11轉(zhuǎn)發(fā)功能
參考實例
基于ssh協(xié)議,遠程訪問服務(wù)器主機系統(tǒng):
[root@linuxcool ~]# ssh 192.168.10.10
The authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.
ECDSA key fingerprint is SHA256:ZEjdfRjQV8pVVfu0TSYvDP5UvOHuuogMQSDUgLPG3Kc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.
root@192.168.10.10's password: 此處輸入遠程服務(wù)器管理員密碼
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Tue Dec 14 08:49:08 2022
[root@linuxprobe ~]#
使用指定的用戶身份登錄遠程服務(wù)器主機系統(tǒng):
[root@linuxcool ~]# ssh -l linuxprobe 192.168.10.10
linuxprobe@192.168.10.10's password: 此處輸入指定用戶的密碼
Activate the web console with: systemctl enable --now cockpit.socket
[linuxprobe@linuxprobe ~]$
登錄遠程服務(wù)器主機系統(tǒng)后執(zhí)行一條命令:
[root@linuxcool ~]# ssh 192.168.10.10 "free -m"
root@192.168.10.10's password: 此處輸入遠程服務(wù)器管理員密碼
total used free shared buff/cache available
Mem: 1966 1359 76 21 530 407
Swap: 2047 9 2038
強制使用v1版本的ssh加密協(xié)議連接遠程服務(wù)器主機:
[root@linuxcool ~]# ssh -1 192.168.10.10
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)