8. Resolve SSH Issues Using cloud shell - Ayushi-srivastav/OCI GitHub Wiki

Note : If problematic instance is not connected to any other instance, we need to use the Cloud Shell feature.

Resolving SSH Issues Using cloud shell

Open the Compute section, go to the instance, and click on the right side of the instance page under Developer Tools to select Cloud Shell.

image

Cloud shell is open

image

First we will create public and private key using below command

ssh-keygen

image

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

image

Now,

select the Paste Public Key option and paste the public key that we generated in the cloud shell 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 connection for linux/mac

image

And then run that command in cloud shell

(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 cloud shell 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

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_configbkpnew)

cp sshd_configbkpnew sshd_config

image

image

image

image

Now, there is no diiference b/w both files

diff sshd_config sshd_configbkp

image

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

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 cloud shell

image

Finally, **log in to problematic instance with root user **

image