Root account bị vô hiệu hóa đăng nhập (OVH)
Một số nhà cung cấp máy chủ mặc định vô hiệu hóa người dùng root (chẳng hạn như OVH), 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 tài khoản nhà cung cấp máy chủ tạo cho bạn, chẳng hạn
ubuntu
- 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
Please login as the user “ubuntu” rather than the user “root” (AWS)
Với các máy chủ AWS thì đăng nhập tài khoản root
vào sẽ có thông báo như thế này và mất kết nối. Bạn hãy đăng nhập tài khoản ubuntu
và thực hiện lệnh sau
sudo su
sed -i -e ‘s/.*exit 142″ \(.*$\)/\1/’ /root/.ssh/authorized_keys