dd
重装系统
切换到 root 用户
su -
下载 dd 脚本
国外
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O ${_##*/} $_
国内
curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O ${_##*/} $_
给脚本执行的权限
chmod a+x reinstall.sh
重装系统
--password设置密码--ssh-key设置 SSH 密钥
密码
./reinstall.sh debian 13 --password PASSWORD
密钥
./reinstall.sh debian 13 --ssh-key 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGYWUscHb2fSSHbJIYOAJGaFiImWOgEhomas4KyhC1pG wangzhy'
需要重启
reboot
默认的账号密码
Username: root
Password: 123@@@
系统初始化操作
1、免密登录
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGYWUscHb2fSSHbJIYOAJGaFiImWOgEhomas4KyhC1pG wangzhy' > /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
chown root:root /root/.ssh/authorized_keys
vim /etc/ssh/sshd_config
## 超时
ClientAliveInterval 30
ClientAliveCountMax 6
# 不允许密码登录
PasswordAuthentication no
# 允许密钥登录
PubkeyAuthentication yes
ChallengeResponseAuthentication no
UsePAM no
重启 sshd 服务
systemctl restart sshd
如果配置了并且重启了 ssh 服务,但是还是能通过密码登录。
检查 /etc/ssh/sshd_config.d 下是否有其他文件。
腾讯云下 /etc/ssh/sshd_config.d/ 下有一个 50-cloud-init.conf 文件,里面配置了 PasswordAuthentication yes,需要修改为
no。
2、alias
vim ~/.bashrc
增加以下内容
alias cls='clear'
alias ls='ls -AlFhv --color=auto --group-directories-first'
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
source ~/.bashrc
3、zsh
4、hostname
hostnamectl set-hostname xxx
如果出现 unable to resolve host xxx: Name or service not known, 需要检查下面的文件是否包含 hostname
hostname
cat /etc/hostname
cat /etc/hosts
5、acme
安装 acme.sh
wget -qO- get.acme.sh | bash
生成证书
acme.sh --issue --dns dns_cf -d 398520.xyz -d "*.398520.xyz" -k ec-256 --force
6、cli-proxy-api
安装并启动
curl -fsSL https://raw.githubusercontent.com/brokechubb/cliproxyapi-installer/refs/heads/master/cliproxyapi-installer | bash
cp /root/cliproxyapi/cliproxyapi.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now cliproxyapi.service
systemctl status cliproxyapi.service
停止
systemctl stop cliproxyapi.service
7、ufw
apt install ufw
ufw enable
ufw allow 22/tcp
ufw allow 443/tcp
ufw default deny incoming
ufw default allow outgoing
ufw 删除指定配置
ufw status numbered
ufw delete 3
8、禁用 ipv6
# 向配置文件写入禁用 IPv6 的规则
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
# 让配置立即生效
sysctl -p
监测是否生效
sysctl -a | grep disable_ipv6
CPA 服务器迁移计划
apt install zsh git wget curl nginx htop zip jq nodejs
# zsh
chsh -s $(which zsh)
# on-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# acme
wget -qO- get.acme.sh | bash
# cli-proxy-api
curl -fsSL https://raw.githubusercontent.com/brokechubb/cliproxyapi-installer/refs/heads/master/cliproxyapi-installer | bash
cp /root/cliproxyapi/cliproxyapi.service /etc/systemd/system/
# 复制 root 用户根目录
scp -r sjc:/root/. /root/
scp -r sjc:/opt/. /opt/
scp -r sjc:/etc/nginx/. /etc/nginx/
其他需要修改的
crontab
34 12 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
0 */6 * * * cd /root/cliproxyapi && ./cliproxyapi-installer && systemctl restart cliproxyapi.service
一键安装 docker
bash <(curl -sL 'https://get.docker.com')