跳到主要内容

dd

重装系统

切换到 root 用户

su -

下载 dd 脚本

curl -O https://jihulab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_

给脚本执行的权限

chmod a+x reinstall.sh

重装系统

./reinstall.sh centos 7 

重启后,自动安装 centos 7

reboot

账号密码

centos 7
Username: root
Password: 123@@@

系统初始化操作

1、免密登录

echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1ER+qPm5efChW4Is84XnnHfyBWxzzRvEgILnMfIT+StLpbKM/+4Z+OFWi1oDMu7O1jI+uhoN7aavl9h/6ge3tqY0JFO1H0Fhz1RelGZvYMd+UhhsMJl/k2Zw3vU3AdocCfsEuLo0UKt3qx6J7+xMyibcPIv9BZkuIoezcAHNwzntd5HRzYlizsy7AbaiSDnil3pv2ZLtKgrAWKhxuPAxuwrwHVSHumua6gmPO0+hKwjR1c6Xmu+CdVortLLUlpAdDoTI/NdbPq/0WShEAZs6wjz2OBz+2kl3WLnJqb1FGFuK4qfLWQmwHNwH3lKyxGgv8hG5ol54ta7auajtIP+ijnI98zlzjqAgAQXwRDBurprqWApvbOzJ2pPCfmkLkEqf3HMn6GtxSbCROMlAWOSD6G7gLsOTYh7kEYkHjMHRcnVUYzim3cttBS0xd48rTn1C9EehpYXLIJJi3pOnIRHIa3YOBl8/AWBhjowNH2+GHrJB0PnF2omuZ8szJthtPsE0= root@localhost' > /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

yum install zsh git wget curl

sh -c "$(curl -fsSL https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"

wget -O $ZSH_CUSTOM/themes/haoomz.zsh-theme https://cdn.haoyep.com/gh/leegical/Blog_img/zsh/haoomz.zsh-theme

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

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
vim ~/.zshrc
# 将第11行改为
ZSH_THEME="wedisagree"

# 73 行
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
source ~/.zshrc

4、docker

yum update
yum install docker docker-compose-plugin

5、更新 git 到最新版本

yum install epel-release
yum install https://repo.ius.io/ius-release-el7.rpm
yum remove git
yum install git236