[TH] วิธีการเปิดการใช้งาน root Login สำหรับ Cloud Server CentOS

สำหรับการใช้งาน Cloud Server ครั้งแรก Linux จะปิดการ SSH Login เข้าด้วย root ไว้อยู่ จึงไม่สามารถเข้าเครื่องด้วย root ได้

หลังจากสร้างเครื่อง Cloud Server เจ้าของเครื่องจะได้รับอีเมลแจ้ง Username และ Password เข้าใช้งาน

ให้เข้าเครื่องด้วย Username และ Password ที่ส่งให้ทางอีเมลและเปิดการเข้าใช้งานระดับ root

1. SSH Login ด้วย Username: centos และ Password ที่ได้จากอีเมล เข้าใช้งานครั้งแรกระบบจะบังคับให้เปลี่ยน password ใหม่

(current) UNIX password: = กรอก password ที่ได้รับจากอีเมล
New password: = กรอก password ใหม่ (กรอก password เดิมได้หากต้องการ)
Retype new password: = กรอก password ใหม่อีกครั้ง

หลังจากตั้งรหัสผ่านใหม่ ระบบจะ Logout อัตโนมัติ สามารถ SSH Login เข้าด้วย Username: centos และ Password ใหม่

2. หลังจาก SSH Login ด้วย Username: centos และ Password ใหม่ สามารถเปลี่ยนเป็นสถานะ root ด้วยคำสั่ง

sudo -i

3. ตั้ง Password สำหรับ Root โดยการใช้คำสั่ง

passwd

New password: = กรอก Password สำหรับ root
Retype new password: = กรอก Password สำหรับ root อีกครั้ง

ระบบจะขึ้นข้อความ “all authentication tokens updated successfully”

4. แก้ไขไฟล์ /etc/ssh/sshd_config และเปลี่ยนบรรทัดตามด้านล่างนี้

#PermitRootLogin yes

เป็น

PermitRootLogin yes

บันทึกการแก้ไขของไฟล์ /etc/ssh/sshd_config

5. Restart SSH Server ด้วยคำสั่ง

systemctl restart sshd

จากนั้นสามารถ SSH Login ด้วย user root ได้แล้ว

Was this article helpful?

Related Articles