ubuntu 配置root远程登录shell脚本

以下是一键配置脚本,直接新建rootlogin.sh脚本文件,打开后把以下命令粘贴进去然后,运行脚本文件即可。

shell 复制代码
#!/bin/bash

 #set root password
sudo passwd root
 
#notes Document content
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password
 
#modify profile
sudo sed -i 's/^mesg.*/tty -s \&\& mesg n \|\| true/' /root/.profile
 
#install openssh
sudo apt install openssh-server
 
#delay
sleep 1
 
#modify conf
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
 
#restart server
sudo systemctl restart ssh

运行脚本:

shell 复制代码
sh rootlogin.sh

参考资料:ubuntu22.04桌面版开启root用户登陆并开启root用户远程ssh连接

相关推荐
白鲸开源22 分钟前
Ubuntu 22 下 DolphinScheduler 3.x 伪集群部署实录
java·ubuntu·开源
LH_R8 小时前
OneTerm开源堡垒机实战(四):访问授权与安全管控
运维·后端·安全
Raymond运维9 小时前
MariaDB源码编译安装(二)
运维·数据库·mariadb
JuiceFS1 天前
从 MLPerf Storage v2.0 看 AI 训练中的存储性能与扩展能力
运维·后端
chen9451 天前
mysql 3节点mgr集群部署
运维·后端
LH_R1 天前
OneTerm开源堡垒机实战(三):功能扩展与效率提升
运维·后端·安全
dessler1 天前
Hadoop HDFS-高可用集群部署
linux·运维·hdfs
少妇的美梦2 天前
logstash教程
运维
chen9452 天前
k8s集群部署vector日志采集器
运维
chen9452 天前
aws ec2部署harbor,使用s3存储
运维