linux學習總結 unit07 ssh服務管理

2021-08-04 06:57:04 字數 2328 閱讀 4801

ssh 為 secure shell 的縮寫,是應用層的安全協議。ssh 是目前較可靠,專為遠端登入會話和其他網路服務提供安全性的協議。利用 ssh協議可以有效防止遠端管理過程中的資訊洩露問題。

只要你知道自己帳號和口令,就可以登入到遠端主機。但會出現「中間人」攻擊。

[student@host ~]$ ssh remoteuser@remotehost            //以遠端主機的remoteuser使用者身份登陸連線remotehost主機

remoteuser@remotehost's password:

[student@host ~]$ ssh remoteuser@remotehost hostname          //遠端登陸主機但不進入遠端主機,執行命令hostname,返回命令結果

remoteuser@remotehost's password:

remotehost.example.com

你必須為自己建立一對密匙,把公匙放在需要訪問的伺服器上。如果你要連線到ssh伺服器上,客戶端軟體就會向伺服器發出請求,請求用你的密匙進行安全驗證。伺服器收到請求之後,先在該伺服器上你的主目錄下尋找你的公匙,然後把它和你傳送過來的公匙進行比較。如果兩個密匙一致,伺服器就用公用密匙加密「質詢」(challenge)並把它傳送給客戶端軟體。客戶端軟體收到「質詢」之後就可以用你的私人密匙解密再把它傳送給伺服器。

實驗準備:兩台伺服器

desktop 172.25.0.10

server 172.25.0.11

目的:實現desktop主機無密碼連線server主機

1. server主機上生成公鑰和私鑰,儲存在當前使用者家目錄的.ssh目錄下;

[root@server0 ~]# ssh-keygen                     //生成公鑰私鑰工具

[root@server0 ~]# ls /root/.ssh///id_rsa:私鑰,就是鑰匙

id_rsa id_rsa.pub         //id_rsa.pub:公鑰,就是鎖

2. 分發鑰匙給client主機

[root@server0 ~]# scp /root/.ssh/id_rsa [email protected]:/root/.ssh/

3. 測試

[root@desktop0 ~]# ssh [email protected]             //通過id_rsa直接連線不需要輸入使用者密碼

last login: mon oct 3 03:58:10 2016 from 172.25.0.25

配置檔案的幾個引數;

passwordauthentication yes|no          //是否開啟使用者密碼認證,yes為支援no為關閉

permitrootlogin yes|no             //是否允許超級使用者登陸

allowusers student westos      //使用者白名單

denyusers westos   //使用者黑名單ssh服務安全配置

配置檔案的幾個引數;

passwordauthentication yes|no     //是否開啟使用者密碼認證,yes為支援no為關閉

permitrootlogin yes|no      //是否允許超級使用者登陸

allowusers student westos    //使用者白名單

denyusers westos   //使用者黑名單

systemctl status sshd //檢視ssh服務的狀態

systemctl stop sshd //關閉ssh服務

systemctl start sshd //開啟ssh服務

systemctl restart sshd //重新啟動ssh服務

systemctl enable sshd //設定sshd服務開機啟動

systemctl disable sshd //設定sshd服務開機關閉

systemctl list-units //列出當前系統服務的狀態

systemctl list-unit-files //列出服務的開機狀態

systemctl mask sshd //鎖定ssh服務,不能啟動服務,除非解鎖

systemctl unmask sshd //解鎖ssh服務

systemctl set-default multi-user.target //開機不開啟圖形

systemctl set-default graphical.target //開機啟**形

Linux學習總結 unit02檔案管理

絕對路徑 完全限定的名稱,從根目錄 開始查詢,路徑的寫法 一定由根目錄 寫起 相對路徑 從當前所在目錄開始查詢,不會以 開頭。判斷 root 絕對 home kiosk 絕對 usr share 相對 desktop 相對 pwd 顯示當前所在目錄 cd 更改或切換目錄的命令 幾個特殊的目錄 代表此...

linux入門學習筆記 07

本節主要講 gdb shutdown rpm yum apt get 和 mount 目錄 gdb 用法 shutdown 和 reboot rpmmount umount usb前一節講了 gcc 是編譯用的,gdb 則是除錯用的,類似於 vs 中的 debug,可以斷點 單步除錯 gcc g o...

Linux 基礎學習之Unit3例項

linux 基礎學習之unit3例項 1.man man manual man是手冊縮寫 man man 檢視man命令的幫助 man passwd 檢視passwd命令的幫助和 h help一樣 man的級別 1 系統命令 2 系統介面 3 函式庫 4 特殊檔案,比如裝置檔案 5 檔案 6 遊戲 ...