Securing Data

本文主要出自於參考轉載 Weithenn, Unit3-Securing Data
Lab1. 設定 SSH key with no passphrase
Server1 主機利用 SSH 方式登入 Client 主機不用打密碼,產生的 SSH Key 未使用密碼進行保護,在 Server1 上設定資訊如下

#ssh-keygen -t dsa  //產生 .ssh/id_dsa 及 id_dsa.pub (man ssh-keygen)
#ssh-copy-id -i ~/.ssh/id_dsa.pub 192.168.0.100 //將 Public Key 複製到 Client 主機 IP 為 192.168.0.100
root@116.50.43.82's password:
密碼輸入正確後會將 Server1 端的 id_dsa.pub 複製到 Client 並自動改名為 authorized_keys,當然你也可以手動用 scp 複製然後改名 (man ssh-keygen),完成上述設定後以後從 Server1 主機利用 SSH 方式登入 Client 主機便不用再打密碼
[root@server .ssh]# ssh 192.168.0.100 //從 Server1 主機 SSH 欲登入 Client 主機 Last login: Sun Nov 8 10:03:34 2009 from server1.example.com //不用密碼即可登入 [root@client ~]#
Lab2. SSH key with passphrase
Server1 主機利用 SSH 方式登入 Client 主機不用打密碼,產生的 SSH Key 有使用密碼進行保護,在 Server1 上設定資訊如下

 #ssh-keygen -t dsa   //產生時有輸入 passphrase 來保護 SSH Key
 #eval $(ssh-agent)   //啟動 ssh-agent
 Agent pid 18234
 #ssh-add             //ssh-agent 有啟動成功此指令才可順利執行
 Enter passphrase for /root/.ssh/id_dsa:   //輸入剛才設定的密碼
 Identity added: /root/.ssh/id_dsa (/root/.ssh/id_dsa)
 #ssh-copy-id -i id_dsa.pub client  //把 ssh key 複製到 client 端
 #ssh client                        //雖然 ssh 有使用 passphrase 保護,但仍可直接登入
但 ssh-add 為 By Session (所以另開視窗就無效) 如下列,另開視窗再次登入 Client 便會詢問 Passphrase (自動化機制受到干擾),若你輸入錯誤的話代表 SSH Key 無效,所以換詢問 Client 主機密碼
#ssh client Enter passphrase for key '/root/.ssh/id_dsa': //輸入正確順利登入 client Last login: Sun Nov 8 10:33:34 2009 from server1.example.com #ssh client Enter passphrase for key '/root/.ssh/id_dsa': Enter passphrase for key '/root/.ssh/id_dsa': Enter passphrase for key '/root/.ssh/id_dsa': //三次輸入錯誤 (表示 ssh key 無效) root@client's password: //換問 Client 密碼 Last login: Sun Nov 8 10:35:07 2009 from server1.example.com
Lab3. 設定 SSH Tunnel with VNC
Client (VNC Client) 再本機 Listen port 6000 然後連到遠端 (VNC Server Port 6000)

 #ssh -L 6000:server:6000 server
 #vncviewer localhost:6000

留言

這個網誌中的熱門文章

Json概述以及python對json的相關操作

Docker容器日誌查看與清理

遠程控制管理工具ipmitool