用于遠端連接配接 Secure Shell Protocol
預設端口 22 協定版本 ssh2
主要包含 ssh遠端連接配接 SFTP服務
服務端OpenSSH
# rpm -qa openssh openssl
openssh-5.3p1-94.el6.x86_64
openssl-1.0.1e-15.el6.x86_64 負責加密
程序
# ps -ef | grep sshd
root 1243 1 0 19:06 ? 00:00:00 /usr/sbin/sshd
支援RSA DSA密鑰
公鑰Public key 密鑰Pivate key
1.X版本
# less /etc/ssh/sshd_config 配置檔案
# grep ServerKey /etc/ssh/sshd_config 臨時公鑰
#ServerKeyBits 1024
# ssh [email protected] 會接受服務端的公鑰
The authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.
RSA key fingerprint is c6:94:5f:af:17:75:7f:dd:bc:2a:54:83:f3:5a:d2:dc.
Are you sure you want to continue connecting (yes/no)?
用戶端會生成 Private Key # cat /etc/ssh/ssh_config
# ll ~/.ssh/known_hosts
-rw-r--r-- 1 root root 395 4月 3 19:37 /root/.ssh/known_hosts
ServerKey + Private Key =Key pair 生成此密鑰對,,,,通過此交換資料
危險: 此後交換資料不檢查 key pair
Version 2 多加了一個确認聯機正确性的Diffie - Hellman 機制
檢查資料的來源是否正确。
基于密碼
基于密鑰
# netstat -lntup | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1162/sshd
tcp 0 0 :::22 :::* LISTEN 1162/sshd
# lsof -i :22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1162 root 3u IPv4 10478 0t0 TCP *:ssh (LISTEN)
sshd 1162 root 4u IPv6 10480 0t0 TCP *:ssh (LISTEN)
sshd 1437 root 3r IPv4 11491 0t0 TCP 192.168.10.11:ssh->bogon:62818 (ESTABLISHED)
# nmap 192.168.10.10 -p1-65535 掃描端口
基本指令
# ssh [email protected]
# ssh [email protected] ifconfig
# scp xx [email protected]:/tmp cp檔案 xx 到 /tmp
# scp [email protected]:/tmp/xx . 相反
SFTP
# sftp [email protected]
put /root/xx /tmp 上傳 加用戶端本地路徑
sftp> get /root/xx /tmp 下載下傳到本地的目前目錄
本文轉自 295631788 51CTO部落格,原文連結:http://blog.51cto.com/hequan/1761324,如需轉載請自行聯系原作者