7. Resolve SSH Issues Using Serial Console connection - Ayushi-srivastav/OCI GitHub Wiki

Note : If both instances are in the same subnet, we can use healthy Instance to access problematic Instance.

Access the problematic instance using a healthy instance.

As we can see

We're currently unable to log in to the instance (Test_Instance)

image

image

So, now we will log in to another healthy instance (Test_Instance2) using PuTTY,

and from there, we will try to fix the login issue on the problematic instance (Test_Instance)

image

First, we will check if there is any key saved in the authorized keys in .ssh folder

image

If not, then we will create public and private key using command ssh-keygen

ssh-keygen

and now we can see , public & private key is created

image

After that we will copy the public key using cat command

image

And then, open the problematic instance (Test_Instance) in the console.

Scroll down, select Console Connection, and then choose the Create Local Connection option

image

Now,

select the Paste Public Key option and paste the public key that we generated in the healthy instance using the ssh-keygen command

image

console connection is created and active

image

click in three dot in right corner of created console connection and select copy serial console connectuon for linux/mac

image

And then run that command in putty

(Note: Before running this command, ensure it is executed where the public and private keys were created)

image

Type yes 2 times

image

Now go to the problematic instance and Force Reboot in console

image

And then immediately switch to putty and keep pressing esc (escape key) till we get the below screen

image

Use down arrow to reach to boot manager

image

Press enter

image

Press enter And then immediately press esc

image

Press e

image

Use right arrow to reach end of line And press space bar and then add init=/bin/bash

image

Press ctrl+x

image

As we can see, now we are in local host of problematic instance(Test_Instance) from there we can fix the issue in sshd file

But, as we can see in below screen we have Read only permission for sshd_config file

so, first we have to change the permission using /bin/mount -o remount, rw / command

/bin/mount -o remount, rw /

Then, run the copy command to overwrite the original file (sshd_config) with the backup file (sshd_configbkp)

cp -pr sshd_configbkp sshd_config

image

Now, there is no diiference b/w both files

diff sshd_config sshd_configbkp

Now, switch to the console and delete the created local connection

image

image

Then Force reboot the problematic instance (test_Instance)

image

and you can see in putty we are now out of local host of problematic instance (Test_Instance) and automatically switched to healthy instance (Test_Instance2)

image

Finally, log in to problematic instance with OPC user and reset the password log in for the same

image