VPS初始化流程记录

原博客遗产。

随便记记,看看以后能不能写个一键设置脚本

Base Enviroment

1
2
3
4
5
6
7
8
apt update && apt upgrade

apt install emacs-nox git -y

# git 下载配置
git config --global user.name ""

git config --global user.email ""

SSH and User

/etc/ssh/sshd_config:修改保活,以防终端切出去一会就被踹下线了

1
2
ClientAliveInterval 30
ClientAliveCountMax 60

或者本地.ssh/config中添加

1
2
3
Host host
ServerAliveInterval 30
ServerAliveCountMax 60

添加用户

1
2
3
adduser <username>

usermod -aG sudo <username>

添加公钥

1
2
touch /home/<username>/.ssh/authorized_keys
echo <publickey> >> /home/<username>/.ssh/authorized_keys

上密钥后关闭 root 账户密码登录

1
2
3
4
# 注意,需要先添加一个可以登录的账号再修改此项,以防无法登录

# /etc/sshd/sshd_config
PermitRootLogin prohibit-password

Shell

下载 zsh 和 Oh My ZSH

1
2
3
sudo apt install zsh wget -y

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

下载常用插件

1
2
3
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

启用插件

1
2
3
4
5
6
7
8
9
10
# .zshrc
ZSH_THEME="af-magic"

plugins=(
git
sudo
extract
zsh-autosuggestions
zsh-syntax-highlighting
)