2017年10月15日 星期日

裝機筆記

## 裝機器

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04


* Ubuntu 16.04LTS

Local
```
ssh root@HOST
```

Server
```
apt-get update && apt-get upgrade


dpkg-reconfigure tzdata
```

如果 apt-get update 卡住:https://zach-adams.com/2015/01/apt-get-cant-connect-to-security-ubuntu-fix/


## securing-your-server

### 新增 User

Server

```
adduser apps
adduser apps sudo
passwd apps
mkhomedir_helper apps

exit
```

測試登入
Local

```
ssh apps@HOST
```

### 增加 ssh key

Local

```
ssh-copy-id -i ~/.ssh/id_rsa.pub apps@HOST
```
* 如果沒有 ssh key 記得要先 [generate 一組](https://help.github.com/articles/connecting-to-github-with-ssh/)
* 如果沒有 ssh-copy-id 就跑 `brew install ssh-copy-id`


### Disable Password Authentication

Server

```
sudo vim /etc/ssh/sshd_config
```

Set
```
PasswordAuthentication no
```

```
PubkeyAuthentication yes
ChallengeResponseAuthentication no
```


### deploy 前準備

Server
```
sudo apt-get install git
```

Local
```
ssh-add -L
如果沒有就
ssh-add ~/.ssh/id_rsa
```



沒有留言:

張貼留言