Secure Shell (安全外殼協議,簡稱 SSH )是一種加密的 網絡傳輸協議 SSH 最常見的用途是遠程登錄系統 人們通常利用 SSH 來傳輸 命令行界面 和遠程執行命令。使用頻率最高的場合 Unix 系統 ,但是 Windows 操作系統也能有限度地使用 SSH 2015 年,微軟宣佈將在未來的操作系統中提供原生 SSH 協議支持, Windows  10 1809 版本已提供可手動安裝的   OpenSSH 工具。

測試平臺:   ubuntu14.04(root 用戶 ) - client     ubuntu16.04(fh 普通用戶 ) - server

即ubuntu登錄 ubuntu ,以後有機會和大家分享下 Windows 登錄 Ubuntu 的操作。

1. SSH 分爲 Client Server

Ubuntu 默認自帶 SSH Client ,端口號爲 22 。如果沒有,可通過 sudo apt-get install openssh-client 來安裝。如果作爲 Server 端則需要安裝 SSH Server

2.  安裝 SSH Server 並啓動

①查看 SSH Server 是否安裝

dpkg -l|grep ssh

圖中結果只安裝了SSH Client

②安裝 SSH Server

sudo apt-get install openssh-server

③查看是否安裝成功 && 查看是否啓動成功

1> dpkg -l|grep ssh

圖中結果說明SSH Server安裝成功

2> ps -e|grep ssh

有sshd說明 SSH Server 已經啓動成功

如果沒有啓動,可通過以下兩種方式啓動:

sudo /etc/init.d/ssh start

sudo service ssh start

3. SSH Server相關配置

SSH Server配置文件在 /etc/ssh/sshd_config

①這裏可以設置 SSH Server 端口,默認是 22 ,圖中已修改爲 666

②允許 root 用戶以任何認證方式登錄

屏蔽PermitRootLogin without-password,增加 PermitRootLogin yes

③重啓 SSH Server

sudo /etc/init.d/ssh stop

sudo /etc/init.d/ssh start

4. Ubuntu root 登錄 SSH

①修改 SSH Client 端口

配置文件在 /etc/ssh/ssh_config

Client 與 Serverping 的通

②終端登錄命令:

ssh   [email protected]

username爲 192.168.15.128 的用戶名稱, 192.168.15.128SSH ServerIP 地址

登錄時需輸入username的 root 密碼

登錄成功如圖:在SSH Client使用 ls 查看當前文件列表

SSH Server 端使用 ls 命令結果對比:

③退出登錄命令

exit

5. 新建文件測試

SSH Client 使用 touch 命令新建 dh.txt 文件

SSH Server 端效果圖

6. SSH Client 使用 scp 命令獲取 SSH Server 端文件

SSH Server 端新建 dh6.txt ,文件內容爲 hello world!

SSH Client 獲取文件

scp username@servername:/path/file   /local_dir (本地目錄)

往期精選文章:

初學Qt(一)

Qt 功能舉例

Qt 高亮關鍵字實現Python編輯器

Qt 項目之虛擬鍵盤V1.1

Qt Model/View 簡便類

Qt Model/View預定義模型

Qt 線程中使用Socket

Qt 收發圖片——圖片拆包、組包與粘包

Python Socket 傳輸圖片

Python 爬取天氣狀況發送給微信好友

Windows10 下 Qt程序打包發佈

擴展和嵌入Python之C++程序中嵌入Python解釋器

一起學習,共同進步。歡迎大家關注公衆號,如果覺得有幫助,請點個在看,十分感謝。

相關文章