# Linux系統管理-HW04(1082944) **設定SSH Key:** 1. 下載putty.exe和puttygen.exe,網址[https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html](https://) 2. 使用puttygen.exe產生公私鑰。把私鑰存下來命名「id_rsa.ppk」,公鑰的內容先貼到記事本,等等會用到。![](https://i.imgur.com/3eQfq0R.jpg) 3. 打開putty.exe,連上server。![](https://i.imgur.com/VJMtTHC.jpg) 4. 在家目錄下創建資料夾,命名.ssh![](https://i.imgur.com/4dJNifQ.jpg) 5. 進入.ssh,創建檔案,命名authorized_keys![](https://i.imgur.com/NpzmYQk.jpg) 6. 用vi打開authorized_keys,把剛剛用puttygen.exe產生的公鑰複製上去。(按i進入編輯模式、按esc離開此mode、輸入「:wq」存檔離開)![](https://i.imgur.com/R2NxUO7.jpg) 7. 關掉putty.exe 8. 打開putty.exe,到SSH>Auth>Credentials匯入私鑰的檔案路徑。![](https://i.imgur.com/Qtw9eWg.jpg) 9. 在Session的HostName欄位輸入: [使用者名稱]@[server IP],之後按下open直接連入server!![](https://i.imgur.com/5SePQYL.jpg) 10. 成功![](https://i.imgur.com/GbizjR4.jpg) **更改Hostname:** 1. 顯示目前主機名稱設定 `$ hostnamectl` ``` Static hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: 50f8c7061d9046bfb883e7cf078f99be Boot ID: 8d2588e972c54d07abe43e0192d0860f Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-957.el7.x86_64 Architecture: x86-64 ``` 2. 輸入指令`$ hostnamectl set-hostname [欲改的名稱]` ```Static hostname: HW04 Icon name: computer-vm Chassis: vm Machine ID: 50f8c7061d9046bfb883e7cf078f99be Boot ID: 8d2588e972c54d07abe43e0192d0860f Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-957.el7.x86_64 Architecture: x86-64 ``` 3. 如此即更改hostname成功!!! **Reference:** 1. [http://blog.itist.tw/2015/03/login-ssh-server-without-username-and-password.html?fbclid=IwAR0TJFRgLgY6rjFR1ZHpYlNZc0wS07fuBzxYR8G24JKJ6-pmuAelilYRSn4](https://) 2. [https://blog.gtwang.org/linux/redhat-centos-7-change-hostname-tutorial/](https://)