mohankumarpaluru / oracle-freetier-instance-creation

A script to create free instance
MIT License
144 stars 27 forks source link

Logging on after instance creation challenges #6

Open cibolo opened 5 months ago

cibolo commented 5 months ago

First, thank you for the work you have put into this.

A bit of a backstory, I signed up before all of the 'Out of host capacity' shenanigans. However, I made the mistake of deleting an instance and was unable to create a new one without your awesome script.

I'm having trouble logging in. I have successfully added a public ip address by going to the attached vnic settings and clicking the three little dots to add an ipv4 address. I ended up creating a "reserved" one and then attempted to ssh to my new instance and this is what I get:

ssh -i id_rsa_private.pub ubuntu@141.X.X.X ubuntu@141.X.X.X: Permission denied (publickey)

I let your script create the ssh keys for me.

Any idea what I'm doing wrong and how to fix?

Thanks!

mohankumarpaluru commented 5 months ago

Hello,

I'm glad to hear that my script has been helpful to you.

Regarding the issue you are encountering, it seems you are using the public key instead of the private key to SSH into your instance. SSH is expecting the private key for authentication

When you generate SSH keys, you typically have a public key (id_rsa_public.pub) and a private key (id_rsa_private). The private key is what you should use to authenticate yourself when connecting via SSH.

cibolo commented 5 months ago

I believe id_rsa_private.pub is the the private key:

ubuntu@la:~/oracle-freetier-instance-creation$ file id_rsa_private.pub id_rsa_private.pub: PEM RSA private key

This is the rest of the folder.

ubuntu@la:~/oracle-freetier-instance-creation$ ls -al total 124 drwxrwxr-x 4 ubuntu ubuntu 4096 Mar 22 19:04 . drwxr-x--- 18 ubuntu ubuntu 4096 Mar 22 19:48 .. -rw-rw-r-- 1 ubuntu ubuntu 16787 Mar 21 18:34 email_content.html drwxrwxr-x 8 ubuntu ubuntu 4096 Mar 21 18:34 .git -rw-rw-r-- 1 ubuntu ubuntu 3085 Mar 21 18:34 .gitignore -rw------- 1 ubuntu ubuntu 1679 Mar 21 19:03 id_rsa_private.pub -rw-rw-r-- 1 ubuntu ubuntu 402 Mar 21 19:03 id_rsa.pub -rw-rw-r-- 1 ubuntu ubuntu 8936 Mar 21 23:41 images_list.json -rw-rw-r-- 1 ubuntu ubuntu 219 Mar 21 23:41 INSTANCE_CREATED -rw-rw-r-- 1 ubuntu ubuntu 138 Mar 21 19:17 launch_instance.log -rw-rw-r-- 1 ubuntu ubuntu 1075 Mar 21 18:34 LICENSE -rw-rw-r-- 1 ubuntu ubuntu 13768 Mar 21 18:34 main.py -rw-rw-r-- 1 ubuntu ubuntu 1730 Mar 21 18:37 oci_api_private_key.pem -rw-rw-r-- 1 ubuntu ubuntu 340 Mar 21 18:40 oci_config -rw-rw-r-- 1 ubuntu ubuntu 485 Mar 21 18:42 oci.env -rw-rw-r-- 1 ubuntu ubuntu 7840 Mar 21 18:34 README.md -rw-rw-r-- 1 ubuntu ubuntu 26 Mar 21 18:34 requirements.txt -rw-rw-r-- 1 ubuntu ubuntu 340 Mar 21 18:40 sample_oci_config -rw-rw-r-- 1 ubuntu ubuntu 3238 Mar 21 23:41 setup_and_info.log -rwxrwxr-x 1 ubuntu ubuntu 601 Mar 21 18:34 setup_init.sh drwxrwxr-x 5 ubuntu ubuntu 4096 Mar 21 18:57 .venv

Am I using the wrong key?

Thanks!

mohankumarpaluru commented 5 months ago

ahh.. my bad. that's the correct key.

can you try to set the key permissions to 600 and then try logging in ?

chmod 600 id_rsa_private.pub

cibolo commented 5 months ago

Same problem: ls -al id_rsa_private.pub -rw------- 1 ubuntu ubuntu 1679 Mar 21 19:03 id_rsa_private.pub

ssh -i id_rsa_private.pub ubuntu@141.XXX ... Permission denied (publickey).

Any other ideas

mohankumarpaluru commented 5 months ago

It seems like the issue might be related to the SSH configuration or permissions.

you can try this :

Stop the instance and navigate to the boot volume section. Detach the boot volume. Go to a VM.Standard.E2.1.Micro instance. In the block volumes section, attach the previously detached volume to the VM.Standard.E2.1.Micro instance.

After completing these steps, access the .ssh folder of ARM instance volume and inspect the authorized_keys file along with its permissions. You can also generate new SSH keys and append them to the authorized_keys file for access.

@cibolo if you think this is too much work, your last option would be just delete, re run the script and wait, if you are not doing it already.