---
# System prepended metadata

title: Linux HW04
tags: [Linux]

---

###### tags: `Linux`
# Linux HW04
操作步驟
## 登入系統
指令：
```=
ssh s1094845@10.2.200.196
```
![](https://i.imgur.com/5qYcQmD.png)

## 伺服器端
### 用 ssh-keygen 指令產生公鑰(id_rsa.pub)跟私鑰(id_rsa)
```=
ssh-keygen
cd ~/.ssh
ls
cat id_rsa.pub
```
![](https://i.imgur.com/i6wuceI.png)

![](https://i.imgur.com/imk11gs.png)

### 改權限，建立私鑰檔
把"~/.ssh"的檔案權限改成700, 把私鑰(id_rsa)的檔案權限改成600, 建立"~/.ssh/authorized_keys"這個檔案, 並把檔案權限改成600
```=
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
```
![](https://i.imgur.com/0uiu1Hz.png)

### append 公鑰
把公鑰(id_rsa.pub)的內容append到authorized_keys中
```=
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cd ~/.ssh
ls
cat id_rsa.pub
cat authorized_keys
```
![](https://i.imgur.com/RILETP7.png)


## 客戶端
### 把私鑰(id_rsa)載回客戶端
```=
scp -r s1094845@10.2.200.196:~/.ssh testssh
```
![](https://i.imgur.com/cBaZY89.png)

![](https://i.imgur.com/7bm26ms.png)

**複製到/user/.ssh**

![](https://i.imgur.com/orKcg1R.png)

### 轉成ppk檔
用PuTTYgen轉成PieTTY支援的格式(用Load選擇All Files找id_rsa)
![](https://i.imgur.com/t8ygBzs.png)
![](https://i.imgur.com/QsQOPnv.png)
![](https://i.imgur.com/ZwLryoR.png)


### 修改PieTTY設定
* 設定ip
![](https://i.imgur.com/fZ2ggQm.png)
* 設定帳號
![](https://i.imgur.com/0IRNXHA.png)
* 設定密碼
![](https://i.imgur.com/79Pjyro.png)
* 把設定存檔
![](https://i.imgur.com/rqvyHZD.png)
* 完成
![](https://i.imgur.com/jWCX6A0.png)

## 登入成功
![](https://i.imgur.com/J8c9mE2.png)

## 重點檢查
ssh自動連線與連線後的帳號及hostname
```=
lsb_release -a
hostname
//找IP
ifconfig
```
![](https://i.imgur.com/wEWyi70.png)



