**这是本文档旧的修订版!**
<markdown>
Ubuntu 14.04 服务器搭建最简 check list
步骤
1、使用 root 用户 ssh 登录
2、创建新用户,并给其 sudo
权限
adduser newbie gpasswd -a newbie sudo
3、切换到新用户,并配置 ssh key
su - newbie mkdir .ssh chmod 700 .ssh vi .ssh/authorized_keys # paste your key chmod 600 .ssh/authorized_keys
4、修改 sshdconfig
sudo vi /etc/ssh/sshd_config
> Port 4917 # change ssh port(optinal)
> AllowUsers newbie # restrict only newbie can login through ssh
sudo service ssh restart
5、简单配置 ufw
sudo ufw allow {port}/tcp
sudo ufw show added
sudo ufw enable
6、设置 PS1
txtred='\[\033[0;31m\]' # Red
txtylw='\[\033[0;33m\]' # Yellow
txtrst='\[\033[0m\]' # Text Reset
PS1="\u@${txtylw}\h${txtrst}:${txtred}\w${txtrst}$ "
7、更改 hostname
sudo vi /etc/hostname
sudo service hostname start
8、更改 ssh welcome message
> - /etc/motd: The classic, static file. Does not exist anymore in Ubuntu 16.04 LTS, not even as a symbolic link to /var/run/motd. If it is created, however its contents will be printed too.
> - /var/run/motd: This was used by Ubuntu’s first implementation. It is not used anymore. It is just ignored by PAM.
> - /var/run/motd.dynamic: This is what is shown on login currently. It is updated by /etc/init.d/motd at every boot. It is also updated by PAM by running the scripts in /etc/update-motd.d/, if they exist.
> - /etc/motd.tail: The Ubuntu package used to populate /etc/update-motd.d. One of them would cat the contents of this file so it was easy to add static content. That script does not exist in the package anymore, so the file does not have the intended effect.
主要修改以下两处文件
- /etc/motd
- /etc/update-motd.d/ 下面的文件
see this post
## 使用 zsh
### 安装
sudo apt-get update
sudo apt-get install zsh
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
chsh -s /bin/zsh
—
## 备注
- 使用 docker 时,需要在 /etc/docker/daemon.json
中加入 "iptables": false
,否则 ufw 的配置会失效。
## Refs
- Server Hacks New Ubuntu 14.04 Server Checklist
- Ubuntu Linux 中安裝 Zsh 及 Oh-my-zsh
- docker/issues/4737
</markdown>