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)
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)
First, we will check if there is any key saved in the authorized keys in .ssh folder
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
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 healthy instance 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 connectuon for linux/mac
And then run that command in putty
(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 putty 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_configbkp)
cp -pr sshd_configbkp 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 healthy instance (Test_Instance2)
Finally, log in to problematic instance with OPC user and reset the password log in for the same