<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 sshd 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 — ### 备注 - 使用 docker 时,需要在 /etc/docker/daemon.json 中加入 "iptables": false,否则 ufw 的配置会失效。 ### Refs - Server Hacks New Ubuntu 14.04 Server Checklist - docker/issues/4737 </markdown>