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.
Cloud shell is open
First we will create public and private key using below command
ssh-keygen
and now we can see , public & private key is created
After that we will copy the public key using cat command
And then, open the problematic instance (Test_Instance) in the console.
Scroll down, select Console Connection, and then choose the Create Local Connection option
Now,
select the Paste Public Key option and paste the public key that we generated in the cloud shell using the ssh-keygen command
console connection is created and active
click in three dot in right corner of created console connection and select copy serial console connection for linux/mac
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)
Type yes 2 times
Now go to the problematic instance and Force Reboot in console
And then immediately switch to cloud shell and keep pressing esc (escape key) till we get the below screen
Use down arrow to reach to boot manager
Press enter
Press enter And then immediately press esc
Press e
Use right arrow to reach end of line And press space bar and then add init=/bin/bash
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
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
Then Force reboot the problematic instance (test_Instance)
and you can see in putty we are now out of local host of problematic instance (Test_Instance) and automatically switched to cloud shell
Finally, **log in to problematic instance with root user **