🔒 Closed Enable root and password login at prelaunch(no need to create key pair) of AWS EC2/Lightsail DEBIAN/UBUNTU instances

Status
Not open for further replies.

joey the cockroach

Forum Master
*NOTE: Tested on DEBIAN and UBUNTU instances only.

EC2 :
In the "Configure Instance" tab go to Advanced Details, then copy and paste these inside the box (see pictures below)

Code:
#!/bin/bash

sed -i "s/PermitRootLogin no/PermitRootLogin yes/" /etc/ssh/sshd_config
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/" /etc/ssh/sshd_config

sed -i "s/#PasswordAuthentication.*/PasswordAuthentication yes/" /etc/ssh/sshd_config
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/" /etc/ssh/sshd_config

systemctl restart sshd

echo "root:youpasswordhere" | chpasswd

*NOTE: Change yourpasswordhere with your desired password

nblrt.PNG

nblrt2.PNG

Optional:
You can now choose to proceed without a key pair.

nblrt3.PNG



LIGHTSAIL:
Click on "+ Add launch script", then paste the same script you used with EC2 above, then proceed to create.

nblrt_lghtsl.PNG

nblrt_lghtsl2.PNG
 
Status
Not open for further replies.

About this Thread

  • 32
    Replies
  • 2K
    Views
  • 14
    Participants
Last reply from:
PHC-XrjgamerX

Trending Topics

Online now

Members online
1,171
Guests online
2,991
Total visitors
4,162

Forum statistics

Threads
2,330,179
Posts
29,252,215
Members
1,152,902
Latest member
jobiebujibuja
Back
Top