跳到主要内容

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 -alF --ignore=. --ignore=.. --color=auto --group-directories-first'
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
source ~/.bashrc

3、zsh

https://blog.wangzhy.com/zsh

4、hostname

hostnamectl set-hostname xxx

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