1 更新系统
只检查不更新
apt update
更新已安装
apt upgrade
2 安装软件
apt install -y net-tools
apt install -y vim
3 创建非root用户,并赋予sudo权限
adduser username
vim /etc/sudoers
4 时间同步,并写入硬件时钟
apt-get install -y ntpdate
ntpdate time.windows.com
hwclock --localtime --systohc
5 修改ssh端口,禁止root登录(安全期间吗)
允许root远程登录
5.1 修改ssh端口
配置:`/etc/ssh/sshd_config`
编辑:找到`#Port 22`所在行,复制内容并修改`Port 2222`
5.2 禁止root远程登录
配置:`/etc/ssh/sshd_config`
编辑:找到`PermitRootLogin yes`所在行,复制并修改`PermitRootLogin no`
当然提前备份一下文件也是极好的.
5.3 重启ssh服务
service sshd restart
验证:
ssh [用户名]@[IP] -p 端口号[默认:22]
尝试用新的用户xxx链接,端口号为2222
ssh xxx@127.0.0.1 -p 2222
**5.4 切换root **
执行命令: su - root 即可.(su - 可将用户和Shell环境切换成root身份)
6 改造你的terminal
体验
6.1 查看是否当前是否有zsh(兼容bash,并且提供了改进,可自定义主题,)
cat /etc/shells
没有则安装
apt-get install -y zsh
6.2 安装oh my zsh
(过程稍微慢一丢丢,还可以接受)
apt-get install -y git
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
安装过程

7 docker
7.1 安装
这里我用的是普通用户
#移除旧程序
sudo apt-get remove docker docker-engine docker.io containerd runc
# 安装新程序
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
建立 docker
组:
sudo groupadd docker
当前用户加入 docker
组:
sudo usermod -aG docker $USER
启动
sudo systemctl enable docker
sudo systemctl start docker
7.1 添加中国镜像
编辑文件/etc/docker/daemon.json,没有就新建。
这里使用163为例子
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
重启docker daemon
sudo systemctl restart docker
测试:
docker run --name nginx-test -p 80:80 -d nginx

图形化管理工具 - Portainer
docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name prtainer-test docker.io/portainer/portainer

8 替换阿里源(centos 请使用yum源)
cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
网友评论