Hướng dẫn đăng nhập và đổi mật khẩu quyền root với vps OVH

Máy chủ OVH mặc định vô hiệu hóa người dùng root . thay vào đó có 1 tài khoản người dùng chẳng hạn ubuntu và người dùng này có thể lên quyền root

Để cho phép root login bạn làm như sau

SSH Login vào với quyền ubuntu bằng bitvise ssh hoặc phần mềm gì

Sau đó copy lệnh dưới đây và dán vào terminal

if [ "$EUID" -ne 0 ]; then
sudo su
fi

# Find the line in the file that contains "PermitRootLogin"
line1=$(grep -n -m 1 "^#*\s*PermitRootLogin" /etc/ssh/sshd_config | cut -d: -f1)
# Replace the line with "PermitRootLogin yes"
sed -i "${line1}s/.*/PermitRootLogin yes/" /etc/ssh/sshd_config

# Find the line in the file that contains "PasswordAuthentication"
line2=$(grep -n -m 1 "^#*\s*PasswordAuthentication" /etc/ssh/sshd_config | cut -d: -f1)
# Replace the line with "PasswordAuthentication yes"
sed -i "${line2}s/.*/PasswordAuthentication yes/" /etc/ssh/sshd_config

# Restart the ssh service to apply the changes
systemctl restart ssh

# Doi mat khau cho user root
sudo passwd root