4. Enabling Password based access for Root user - Ayushi-srivastav/OCI GitHub Wiki
Steps to enable password access
Step 1 : Open putty
- Open Putty App
Paste Public IP under session category
- Select location for putty log file under Logging category
- Browse and select private PPK format key file under Auth category under SSH
And click on Open
Now Putty is open.
Step 2 : Switch from opc user to root user
as we are login first time, we will login from opc user
- Switch to root user
Sudo su -root
- Now set password for root user
passwd root
and then write password.
Step 3 : Enable password based login
- Go to the ssh service under etc directory
cd /etc/ssh
and list all files & directories in ssh
ls -lrth
- Now take backup of sshd_config file using copy command
cp sshd_config sshd_config_bkp
*sshd_config_bkp (backup file name)
and again list all files & directories to check backup file is created or not.
ls -lrth
- After taking backup, we open the sshd_config file and edit it
vi sshd_config
- Look up permit root login, then add permit root login yes below, ensuring it isn't preceded by #, using the Insert button.
- Search for password authentication then add password authentication yes below, ensuring it isn't preceded by #, using the Insert button.
(6) Next,Find the path where changes can be made to enable password authentication.
Press shift / include
and we will get the path for file (In which we have to do modification)
Include /etc/ssh/sshd_config.d/*.conf
(7) Next, exit from file sshd_config and run again ls -lrth and look for sshd_config.d
Enter in sshd_config.d folder and run ls -lrth
and look for 50-cloud-init.conf file
Now, Run vi 50-cloud-init.conf
Search for password authentication and change it to yes, using Insert Button.
To save the file
:wq!
(shift+: wq!)
enter
- check difference between both files before restarting the server
diff sshd_config sshd_config_bkp
- Now check the status of the server as well
systemctl status sshd
- lastly Restart the server
systemctl restart sshd
- Before logging out of the current session, keep it open and log in from a new session.
If the new session opens successfully, you can log out. If not, try to fix the error in the sshd file while in the current session.