最近来来回回折腾了十几次 BuyVM 的 VPS,每次折腾总要做一些重复的操作,挺麻烦,干脆记录一些常用操作,方便日后复制粘贴。

修改时区

修改为 UTC 时区:timedatectl set-timezone UTC
修改为中国时区:timedatectl set-timezone Asia/Shanghai

重新安装 vim

apt update
apt remove vim-common -y
apt install vim -y

生成 SSH 登录密钥

ssh-keygen
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

修改 SSH 配置

vi /etc/ssh/sshd_config

Port 12345
PubkeyAuthentication yes
PasswordAuthentication no
ClientAliveInterval 300
ClientAliveCountMax 10

service ssh restart

BuyVM 挂载数据盘

查询硬盘:ls /dev/disk/by-id/
格式化:mkfs.ext4 -F /dev/disk/by-id/scsi-0BUYVM_SLAB_VOLUME-0000
挂载:mount -o discard,defaults /dev/disk/by-id/scsi-0BUYVM_SLAB_VOLUME-0000 /data
开机挂载:echo '/dev/disk/by-id/scsi-0BUYVM_SLAB_VOLUME-0000 /data ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab

安装 Node.js

curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt install nodejs -y
npm install npm -g