Oracle Cloud Instance Linux 8.5 -- Unable to Fix Corrupted SSH Key - oracle

I have Oracle Linux 8.5 in Oracle Cloud, and have been using the host for several months.
But today I was trying to setup vscode remote ssh and looks like I messed up the ssh key that I use to login to the host. Now I cannot!
I tried to follow this documentation and this thread to fix some commands.
However, that did not help! And in fact now the host having difficulty stopping quickly; rebooting looks fine.
Any ideas on how to correct this issue?! (Was having a lot of fun until this struck :) )

In the OCI console, go to the instance, and click on the "console connection", this will show you 2 options, one is create local connection, which will allow you to upload a new ssh key file. Or you can create a console connection and then update the authorized_keys file with your new id_rsa.pub contents

Console connection did NOT work for me. That's why I went by attaching the volume to another instance. The documentation I followed suggests to mount /dev/sdb3. However that did not work for me. Instead, I mounted /dev/ocivolume/root, and modified the ssh key there, and now works!

Related

Connecting to remote server with SSH keys

I have been trying to figure out where I am going wrong for a few days now.
I am trying to set up a pair of SSH keys, so my computer can remotely connect to my web server and run a script without a password.
I have generated the SSH keys on my Mac and placed the public key on the server in the '.ssh' folder, then added this to the 'authorized_keys' file.
When I run my command through terminal, I get the following, asking for both a passphrase and the password still.
Christophers-MacBook-Pro:~ christopherdavies$ bash /Users/christopherdavies/Desktop/rsync/chrisdavies/chrisdavies.sh
Enter passphrase for key '/Users/christopherdavies/.ssh/id_rsa':
chrisdavies#shell.host.co.uk's password:
Am I right to have placed the public key from my SSH keys pair on my Mac onto the server?
I am a bit lost here, so would really appreciate some advice. I am slowly learning, but feel I may be doing something blatantly obviously wrong...
It seems you are off to a good start. Some things to check:
make sure you stored the public key under .ssh/authorized_keys on the same user to which you intend to connect. In your case, it seems that your remote user is "chrisdavies", so it should be under ~chrisdavies/.ssh/autorized_keys.
make sure your script connects to the remote server as "chrisdavies". You might want to check that because you are under a different user on your MacBook "christopherdavies".
To troubleshoot, try to SSH to the remote server instead of running the script directly. If you run "ssh chrisdavies# and it works without the password, you do not have connectivity issues, and you'll need to look into your script.
I hope that helps!

ORA-12541 TNS :no listener on 1 specific remote database, but not on others

Some context: I'm setting up an environment to run some Ruby code our Lead wrote to connect to some remote Databases. I'm using Win10 and have WSL installed. I have installed SQL*Plus, docker, and Ruby, and am sure I have installed all the dependent gems (actually at this point I know for a fact its not a ruby problem). I'm using Docker to use a pre-built image of an Oracle Database, and I have populated it with data.
Obfuscated company DB information:
'Broken' DB (TNS no listener)
Username: W-WORK-DEV
Password: password
Host: host1
Port: 999
SID: W-WORK-DB.tech.company
'Working' DB (can connect just fine)
Username: C-OLD-DEV
Password: password
Host: host2
Port: 999
SID: C-OLD-DB.tech.company
Please note the names I have provided here are purely for obfuscation, they do not represent anything about age or even config. They are essentially the same, just different databases on different hosts. Also note this is a corporate company and would have a lot of base infrastructure for their internal network.
The issue I am having is that with the specific database I am working on, I cannot connect to it. I connect to the company intranet via a VPN (I work offsite) and have issues connecting to WORK-DB.tech.company, though I can connect to C-OLD-DB.tech.company. Methods I have tried to connect with:
Oracle SQL Developer
I have inputted all the correct jdbc strings and username / password. Have even asked other people to attempt to connect (at least 3 others). They can all access C-OLD-DB as well as W-WORK-DB. When using this method, I get The network adapter could not establish the connection.
Side note: I'm fairly sure I have connected to the DB just fine in the past, though I can't be certain because I'm fairly new to this team and have only accessed it once, if that.
SQL*Plus via WSL
I installed SQL*Plus because I think Ruby was accessing it in some capacity when running the script. I got to the point where the script was able to connect to my local docker Database, but when it tried to connect to the remote database, it would return TNS: no listener. I attempted this using sqlplus as well and got the same error.
Example:
sqlplus C-OLD-DEV/password#host2:999/C-OLD-DB.tech.company
This command works and connected to the DB jsut fine.
sqlplus W-WORK-DEV/password#host1:999/W-WORK-DB.tech.company
This command gave me TNS: no listener.
During my research I had found mentions about tnsnames.ora, sqlnet.ora, and listener.ora. I have found relevant files around the company intranet and attempted to use them in my own personal environment to no avail (one of the sqlnet.ora files actually stopped me from being able to connect to any) I found mention about a config/database.yml file related to ruby, but our code already has the database information set up and I seem to be getting to the same solution as the script when trying to manually connect via sqlplus.
Here are some relevant environment variables I have set up when doing these installs. I'm thinking that at some point when trying to set up my environment, I messed up some config that changed the way sqldeveloper or sql plus would connect to that database.
$ echo $ORACLE_HOME: /usr/lib/oracle/12.2/client64/
$ echo $TNS_ADMIN: /usr/lib/oracle/12.2/client64/network/admin
$ echo $LD_LIBRARY_PATH: /usr/lib/oracle/12.2/client64/lib
I hope I have provided all the information I have come across and have explained clearly what my issue is, if you have any questions feel free to comment about it so I can clear it up. Thank you for any and all your help.
So my problem ended up being a 'firewall/port' issue. In the end i found out that specific port I was connecting to was blocked, but I thought it was only on my system. Turns out the VPN I'm using was the issue blocking that port. Company has a Primary Data Center and a Secondary one, and apparently the SDC VPN was blocking that port from me. I switched to using the PDC VPN and it worked.
Are you using the 64 bit jdbc drivers?

How to prevent running program on Win or Unix via command line

After a long research here on Stackoverflow and on net I didn't found nothing talking about it. As the title say, how can I do that?
For example: I am owner of a hosted website that allow me to manage the database via PhpMyAdmin. When I try to connect to my database via prompt, the connection never go fine. It could be because of OS settings (right?).
How can I do that (in both OSs).
Thanks in advance.
If I understand your question correctly:
You have a website with a MySql database hosted on your providers servers.
When you try to use your local PC installation of MySql from a command prompt, it will not let you connect.
I use dreamhost.com and have a similar setup. If I want to use database tools from my local PC to connect to the database, I have to enter my IP address in the db configuration page under "allowed hosts".
Restricting remote database connections to specific IP addresses protects your database from random hacking attempts.
As for your question about restricting command line execution of a program, that is usually just caused by missing configuration information in the environment variables - leaving the path to the executable out of the PATH variable is a common one. You would still be able to run the program if you enter the full path to it.
It really depends on the error message you get when trying to run the program from the command line.

Issue setting up GIT with SSH on Windows Server 2008

I´m following the steps outlined in Tim Davis´ blog for setting up GIT with copSSH on Windows (http://www.timdavis.com.au/git/setting-up-a-msysgit-server-with-copssh-on-windows/) but I´m having problems. I´ve gotten up to step 15 under the Installing Putty instructions but rather than getting a "Enter Login" message, I´m getting a "Network Error: Unable to connect to server" error.
I know that it could potentially be a myriad of things but I was wondering if by some miracle, someone could give me some ideas of what else I should check?
I´ve doublechecked the following:
IP address is correct
User has been added to copSSH
Key is stored in the specified user folder
Rule has been added to Firewall
(NOTE: We´re using a server on 1and1.com and the firewall rules allow us to specify a local port and a remote port. Have configured to local port 4837 and remote port to Any).
I tried to doublecheck if the SSH service is running but I don´t know what it´s called. I noted down the username and password from the copSSH setup but I haven´t seen anything remotely similar to SSH in the list of services.
Any help would be greatly appreciated!! I´ve never had to do something like this before so I´m a little lost.
Regards,
Kat
Troubleshooting
Are you specifying port 4837 in the Putty window?
I personally suggest using OpenSSH or SmartGit, not Putty... I've seen too many issues with it.
Also, I suspect your firewall configuration needs to be local port=Any and remote port=4837.
The 5 minute shortcut
This installer sets up a windows git server using CopSSH. It configures the firewall, the user accounts, and gives you a GUI for all the SSH and keys stuff. It costs $9, but it saves hours of configuration (it's a 5 minute, 3-step install). It has a self-contained Git install, so no conflicts should happen.
NOTE: I'm the webmaster of windowsgit.com. I got the project started after taking a good look at Davis' tutorial and thinking.... oh, ----! The CopSSH author and I collaborated to make the automate the process and reduce the number of frustration-related keyboard deaths :)

ec2 putty connect problem

I have followed Amazon instructions to the letter and it does not work.
ec2-api-tools-1.3-34128 - this is the api tools that I got from Amazon
Set it up following instructions. Checked everything to make sure I follow instructions. When I try to use it, I only get: "invalid.blabla" depending on what command do I try to use.
Anybody with this problem?
I deleted all my instances and all key pairs.
Created new ones (instance and key pair).
Setup putty all over again like instructions say I should do
(creating .ppk file and everything).
Still the problem remains.
When I try to connect to my ec2 instance using putty
I get "login as : " ????????
Also, I am using windows vista.
Is this a problem.
Thanks
Had this same problem. I found that in putty I had to do three things (only 2 of which are mentioned in the amazon guide at http://docs.amazonwebservices.com/AmazonEC2/gsg/2007-01-19/putty.html)
provide the converted private key in the ssh -> Auth section
provide the dns name or IP
go to Connection -> Data and enter "ec2-user" as the Auto-login username
Hope this saves someone else 20 mins!
Did you make sure that you put "root" as the auto-login account in the "Data" section?
A mistake I made than gave me the same error message was setting
"root#ec2-.eu-west-1.compute.amazonaws.com" as the value in the "Host Name (or IP Address)" field in putty.
You need to specify "ubuntu#ec2-.eu-west-1.compute.amazonaws.com".

Resources