取消使用sudo和sudo检测
This commit is contained in:
parent
03855ea490
commit
7e937c202e
@ -57,9 +57,9 @@ bash "${path_script}/Config/${file_name}/${print_array[pick]}.sh" "$path"
|
|||||||
|
|
||||||
chmod +x "${path}/${print_array[pick]}.sh"
|
chmod +x "${path}/${print_array[pick]}.sh"
|
||||||
declare cron_job="${cron} ${path}/${print_array[pick]}.sh"
|
declare cron_job="${cron} ${path}/${print_array[pick]}.sh"
|
||||||
(crontab -l 2>/dev/null | grep -v "${print_array[pick]}.sh") | sudo crontab -
|
(crontab -l 2>/dev/null | grep -v "${print_array[pick]}.sh") | crontab -
|
||||||
(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab -
|
(crontab -l 2>/dev/null; echo "$cron_job") | crontab -
|
||||||
|
|
||||||
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
||||||
|
|
||||||
echo "配置完成"
|
echo "配置完成"
|
@ -51,12 +51,12 @@ if [[ $pick == '1' ]];then
|
|||||||
echo "输入错误"
|
echo "输入错误"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
sudo echo "{\"registry-mirrors\": [\"${url}\"]}" > "/etc/docker/daemon.json"
|
echo "{\"registry-mirrors\": [\"${url}\"]}" > "/etc/docker/daemon.json"
|
||||||
sudo systemctl restart docker 2>> /dev/null|| echo "docker 重启失败"
|
systemctl restart docker 2>> /dev/null|| echo "docker 重启失败"
|
||||||
echo "换源成功"
|
echo "换源成功"
|
||||||
|
|
||||||
elif [[ $pick == '2' ]];then
|
elif [[ $pick == '2' ]];then
|
||||||
sudo docker system prune -af
|
docker system prune -af
|
||||||
echo "清理完成"
|
echo "清理完成"
|
||||||
elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le "${pick_number}" ]];then
|
elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le "${pick_number}" ]];then
|
||||||
declare file_path
|
declare file_path
|
||||||
|
@ -15,10 +15,10 @@ case $pick in
|
|||||||
1)
|
1)
|
||||||
declare password
|
declare password
|
||||||
read -p "请输入root密码:" password
|
read -p "请输入root密码:" password
|
||||||
echo "root:$password" |sudo chpasswd
|
echo "root:$password" |chpasswd
|
||||||
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
||||||
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
sudo systemctl restart sshd.service
|
systemctl restart sshd.service
|
||||||
echo "修改成功当前root密码为:$password"
|
echo "修改成功当前root密码为:$password"
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
@ -45,18 +45,18 @@ case $pick in
|
|||||||
chmod 600 "$HOME/.ssh/authorized_keys"
|
chmod 600 "$HOME/.ssh/authorized_keys"
|
||||||
chmod 700 "$HOME/.ssh"
|
chmod 700 "$HOME/.ssh"
|
||||||
|
|
||||||
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
|
||||||
declare pick2
|
declare pick2
|
||||||
echo "是否关闭密码登录:"
|
echo "是否关闭密码登录:"
|
||||||
read -p "输入 n 取消关闭:" pick2
|
read -p "输入 n 取消关闭:" pick2
|
||||||
|
|
||||||
if [[ ! $pick2 =~ [Nn] ]];then
|
if [[ ! $pick2 =~ [Nn] ]];then
|
||||||
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
sudo systemctl restart sshd.service
|
systemctl restart sshd.service
|
||||||
|
|
||||||
echo "密钥安装完成"
|
echo "密钥安装完成"
|
||||||
;;
|
;;
|
||||||
@ -72,9 +72,9 @@ case $pick in
|
|||||||
useradd -m -s /bin/bash "$user_name"
|
useradd -m -s /bin/bash "$user_name"
|
||||||
|
|
||||||
if grep -q "^$user_name " /etc/sudoers;then
|
if grep -q "^$user_name " /etc/sudoers;then
|
||||||
sudo sed -i "s/^#\?$user_name.*/lsy ALL=(ALL) NOPASSWD: ALL/g" /etc/sudoers
|
sed -i "s/^#\?$user_name.*/lsy ALL=(ALL) NOPASSWD: ALL/g" /etc/sudoers
|
||||||
else
|
else
|
||||||
sudo echo "lsy ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
echo "lsy ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -86,16 +86,16 @@ case $pick in
|
|||||||
if [[ ! $pick =~ [Nn] ]];then
|
if [[ ! $pick =~ [Nn] ]];then
|
||||||
declare password
|
declare password
|
||||||
read -p "请输入密码:" password
|
read -p "请输入密码:" password
|
||||||
echo "$user_name:$password" |sudo chpasswd
|
echo "$user_name:$password" |chpasswd
|
||||||
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
|
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
|
||||||
echo "创建成功"
|
echo "创建成功"
|
||||||
echo "账号:$user_name"
|
echo "账号:$user_name"
|
||||||
echo "密码:$password"
|
echo "密码:$password"
|
||||||
else
|
else
|
||||||
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
su "$user_name" -c "mkdir -p '/home/$user_name/.ssh'"
|
su "$user_name" -c "mkdir -p '/home/$user_name/.ssh'"
|
||||||
sudo cp "/root/.ssh/authorized_keys" "/home/$user_name/.ssh/authorized_keys"
|
cp "/root/.ssh/authorized_keys" "/home/$user_name/.ssh/authorized_keys"
|
||||||
sudo chown lsy:lsy "/home/$user_name/.ssh/authorized_keys"
|
chown lsy:lsy "/home/$user_name/.ssh/authorized_keys"
|
||||||
su "$user_name" -c "chmod 600 '/home/$user_name/.ssh/authorized_keys'"
|
su "$user_name" -c "chmod 600 '/home/$user_name/.ssh/authorized_keys'"
|
||||||
su "$user_name" -c "chmod 700 '/home/$user_name/.ssh/'"
|
su "$user_name" -c "chmod 700 '/home/$user_name/.ssh/'"
|
||||||
|
|
||||||
@ -109,11 +109,11 @@ case $pick in
|
|||||||
read -p "输入 n 取消关闭:" pick2
|
read -p "输入 n 取消关闭:" pick2
|
||||||
|
|
||||||
if [[ ! $pick2 =~ [Nn] ]];then
|
if [[ ! $pick2 =~ [Nn] ]];then
|
||||||
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
||||||
echo "root用户登录已关闭"
|
echo "root用户登录已关闭"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl restart sshd.service
|
systemctl restart sshd.service
|
||||||
|
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
@ -128,30 +128,30 @@ case $pick in
|
|||||||
read -p "输入 n 关闭:" pick2_key
|
read -p "输入 n 关闭:" pick2_key
|
||||||
|
|
||||||
if [[ ! $pick_root =~ [Nn] ]];then
|
if [[ ! $pick_root =~ [Nn] ]];then
|
||||||
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
|
||||||
echo "root用户登录:开启"
|
echo "root用户登录:开启"
|
||||||
else
|
else
|
||||||
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
|
||||||
echo "root用户登录:关闭"
|
echo "root用户登录:关闭"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! $pick2_password =~ [Nn] ]];then
|
if [[ ! $pick2_password =~ [Nn] ]];then
|
||||||
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
echo "密码登录:开启"
|
echo "密码登录:开启"
|
||||||
else
|
else
|
||||||
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
||||||
echo "密码登录:关闭"
|
echo "密码登录:关闭"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! $pick2_key =~ [Nn] ]];then
|
if [[ ! $pick2_key =~ [Nn] ]];then
|
||||||
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
echo "密钥登录:开启"
|
echo "密钥登录:开启"
|
||||||
else
|
else
|
||||||
sudo sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g' /etc/ssh/sshd_config
|
sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g' /etc/ssh/sshd_config
|
||||||
echo "密钥登录:关闭"
|
echo "密钥登录:关闭"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl restart sshd.service
|
systemctl restart sshd.service
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
read -p "请输入需要修改的端口号(默认22): " port_number
|
read -p "请输入需要修改的端口号(默认22): " port_number
|
||||||
@ -165,14 +165,14 @@ case $pick in
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if sudo lsof -i :$port_number -t >/dev/null; then
|
if lsof -i :$port_number -t >/dev/null; then
|
||||||
echo "$port_number 端口已被占用"
|
echo "$port_number 端口已被占用"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo sed -i "s/^#\?Port.*/Port $port_number/g" /etc/ssh/sshd_config
|
sed -i "s/^#\?Port.*/Port $port_number/g" /etc/ssh/sshd_config
|
||||||
|
|
||||||
sudo systemctl restart sshd.service
|
systemctl restart sshd.service
|
||||||
|
|
||||||
echo "端口已经修改为$port_number,记得防火墙放行"
|
echo "端口已经修改为$port_number,记得防火墙放行"
|
||||||
;;
|
;;
|
||||||
|
@ -8,15 +8,15 @@ declare pkg
|
|||||||
if [[ -f "/usr/bin/apt-get" ]];then
|
if [[ -f "/usr/bin/apt-get" ]];then
|
||||||
pkg='apt-get'
|
pkg='apt-get'
|
||||||
install_str+="${pkg} install -y"
|
install_str+="${pkg} install -y"
|
||||||
sudo apt-get update -y
|
apt-get update -y
|
||||||
elif [[ -f "/usr/bin/apt" ]];then
|
elif [[ -f "/usr/bin/apt" ]];then
|
||||||
pkg='apt'
|
pkg='apt'
|
||||||
install_str+="${pkg} install -y"
|
install_str+="${pkg} install -y"
|
||||||
sudo apt update -y
|
apt update -y
|
||||||
elif [[ -f "/usr/bin/pacman" ]];then
|
elif [[ -f "/usr/bin/pacman" ]];then
|
||||||
pkg='pacman'
|
pkg='pacman'
|
||||||
install_str+="${pkg} -Sy --noconfirm"
|
install_str+="${pkg} -Sy --noconfirm"
|
||||||
sudo pacman -Syu --noconfirm
|
pacman -Syu --noconfirm
|
||||||
else
|
else
|
||||||
echo "暂不支持该系统一键安装常用软件"
|
echo "暂不支持该系统一键安装常用软件"
|
||||||
exit
|
exit
|
||||||
@ -92,22 +92,22 @@ if [[ ${soft_dick['docker']} == 2 ]];then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${pkg} == 'apt' || ${pkg} == 'apt-get' ]];then
|
if [[ ${pkg} == 'apt' || ${pkg} == 'apt-get' ]];then
|
||||||
sudo ${pkg} update
|
${pkg} update
|
||||||
sudo ${pkg} install ca-certificates curl -y
|
${pkg} install ca-certificates curl -y
|
||||||
sudo install -m 0755 -d /etc/apt/keyrings
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
sudo curl -fsSL "${docker_img}/linux/${version}/gpg" -o /etc/apt/keyrings/docker.asc
|
curl -fsSL "${docker_img}/linux/${version}/gpg" -o /etc/apt/keyrings/docker.asc
|
||||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
echo \
|
echo \
|
||||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] ${docker_img}/linux/${version} \
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] ${docker_img}/linux/${version} \
|
||||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
sudo ${pkg} update
|
${pkg} update
|
||||||
sudo ${pkg} install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
${pkg} install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
||||||
elif [[ ${pkg} == 'pacman' ]];then
|
elif [[ ${pkg} == 'pacman' ]];then
|
||||||
sudo pacman -Sy docker --noconfirm
|
pacman -Sy docker --noconfirm
|
||||||
sudo systemctl start docker.service
|
systemctl start docker.service
|
||||||
sudo systemctl enable docker.service
|
systemctl enable docker.service
|
||||||
sudo usermod -aG docker $USER
|
usermod -aG docker $USER
|
||||||
newgrp docker
|
newgrp docker
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -121,8 +121,8 @@ if [[ ${soft_dick['Beautify-zsh']} == 2 ]];then
|
|||||||
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
|
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
|
||||||
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-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
|
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
||||||
sudo sed -i 's/^#\?ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc
|
sed -i 's/^#\?ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc
|
||||||
sudo sed -i 's/^#\?plugins.*/plugins=(zsh-syntax-highlighting zsh-autosuggestions command-not-found)/g' ~/.zshrc
|
sed -i 's/^#\?plugins.*/plugins=(zsh-syntax-highlighting zsh-autosuggestions command-not-found)/g' ~/.zshrc
|
||||||
chsh -s /bin/zsh
|
chsh -s /bin/zsh
|
||||||
exec zsh -l
|
exec zsh -l
|
||||||
fi
|
fi
|
||||||
|
@ -40,8 +40,8 @@ deb ${url}/debian/ bookworm main contrib non-free non-free-firmware
|
|||||||
deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware
|
deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware
|
||||||
deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware
|
deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware
|
||||||
EOF
|
EOF
|
||||||
sudo apt update -y
|
apt update -y
|
||||||
sudo apt-get update -y
|
apt-get update -y
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
'bullseye')
|
'bullseye')
|
||||||
@ -50,18 +50,18 @@ deb ${url}/debian/ bullseye main contrib non-free
|
|||||||
deb ${url}/debian/ bullseye-updates main contrib non-free
|
deb ${url}/debian/ bullseye-updates main contrib non-free
|
||||||
deb ${url}/debian/ bullseye-backports main contrib non-free
|
deb ${url}/debian/ bullseye-backports main contrib non-free
|
||||||
EOF
|
EOF
|
||||||
sudo apt update -y
|
apt update -y
|
||||||
sudo apt-get update -y
|
apt-get update -y
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$system" in
|
case "$system" in
|
||||||
'arch')
|
'arch')
|
||||||
sudo pacman -Sy pacman-key --noconfirm
|
pacman -Sy pacman-key --noconfirm
|
||||||
sed -i '/^Server.*/d' "/etc/pacman.conf"
|
sed -i '/^Server.*/d' "/etc/pacman.conf"
|
||||||
echo "Server = ${url}/archlinuxcn/\$arch"
|
echo "Server = ${url}/archlinuxcn/\$arch"
|
||||||
sudo pacman-key --lsign-key "farseerfc@archlinux.org"
|
pacman-key --lsign-key "farseerfc@archlinux.org"
|
||||||
pacman -Syyu
|
pacman -Syyu
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
@ -72,8 +72,8 @@ deb ${url}/ubuntu/ ${version}-security main restricted universe multiverse
|
|||||||
deb ${url}/ubuntu/ ${version}-updates main restricted universe multiverse
|
deb ${url}/ubuntu/ ${version}-updates main restricted universe multiverse
|
||||||
deb ${url}/ubuntu/ ${version}-backports main restricted universe multiverse
|
deb ${url}/ubuntu/ ${version}-backports main restricted universe multiverse
|
||||||
EOF
|
EOF
|
||||||
sudo apt update -y
|
apt update -y
|
||||||
sudo apt-get update -y
|
apt-get update -y
|
||||||
status=1
|
status=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user