vps获取root权限,ssh升级root命令
获取VPS的root权限,随意更改root密码的一键脚本,已测试EUserv德鸡,Hax IPV6,甲骨文oracle、谷歌云gpc、IBM Linux one、亚马逊云azurz等
wget -N https://gitlab.com/rwkgyg/vpsroot/raw/main/root.sh && bash root.sh
脚本具体代码如下:
#!/bin/bash
red='\033[0;31m'
bblue='\033[0;34m'
plain='\033[0m'
red(){ echo -e "\033[31m\033[01m$1\033[0m";}
green(){ echo -e "\033[32m\033[01m$1\033[0m";}
yellow(){ echo -e "\033[33m\033[01m$1\033[0m";}
white(){ echo -e "\033[37m\033[01m$1\033[0m";}
readp(){ read -p "$(yellow "$1")" $2;}
clear
green "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${bblue} ░██ ░██ ░██ ░██ ░██${plain} ░██ ░██ ░██ ░██ ██ ${red}██${plain} "
echo -e "${bblue} ░██ ░██ ░██ ░██${plain} ░██ ░██ ░██ ░██ ░██ ${red}░░██${plain} "
echo -e "${bblue} ░██ ██ ░██${plain} ██ ░██ ██ ░██ ░██ ░${red}██ ${plain} "
echo -e "${bblue} ░██ ██ ${plain} ░██ ██ ░██ ██ ░██ ${red}░██ ░██ ██${plain} "
echo -e "${bblue} ░██ ░${plain}██ ░██ ░██ ░██ ░██ ░${red}██ ░██ ░░██${plain}"
echo -e "${bblue} ░${plain}██ ░░██ ░██ ░░██ ░██ ░░${red}██ ░██ ░██ ██ ██${plain} "
green "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
white "甬哥Gitlab项目 :gitlab.com/rwkgyg"
white "甬哥blogger博客 :ygkkk.blogspot.com"
white "甬哥YouTube频道 :www.youtube.com/c/甬哥侃侃侃kkkyg"
yellow "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
[[ $EUID -ne 0 ]] && su='sudo'
lsattr /etc/passwd /etc/shadow >/dev/null 2>&1
chattr -i /etc/passwd /etc/shadow >/dev/null 2>&1
chattr -a /etc/passwd /etc/shadow >/dev/null 2>&1
lsattr /etc/passwd /etc/shadow >/dev/null 2>&1
prl=`grep PermitRootLogin /etc/ssh/sshd_config`
pa=`grep PasswordAuthentication /etc/ssh/sshd_config`
if [[ -n $prl && -n $pa ]]; then
readp "自定义root密码:" mima
if [[ -n $mima ]]; then
echo root:$mima | $su chpasswd root
$su sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
$su sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
$su service sshd restart
green "VPS当前用户名:root"
green "vps当前root密码:$mima"
else
red "未输入相关字符,启用root账户或root密码更改失败"
fi
else
red "当前vps不支持root账户或无法自定义root密码,建议先执行sudo -i 进入root账户后再执行脚本"
fi
rm -rf root.sh
版权声明:
本站相关资源均存于来自于互联网,和网友投稿发送如果侵权或资源下载地址失效,如遇此情况可于本文留言或tg:@bayuechangan 联系博主,谢谢!!
下载本站软件注意:网站分享的软件资源并非本人原创,使用之前建议虚拟机运行
链接:https://dumuzhou.org/1453.html
文章版权归作者所有
THE END
二维码
文章目录
关闭
共有 0 条评论