AWS EC2 Public Key - ruby-on-rails

I am a first time AWS user, and have been following this tutorial
to set up with Ubuntu. I've generated my keys, saved to my computer, and now I'm at a screen that looks like this:
and the next steps is "put in your key"... I have been searching for hours on the internet, and I can not figure out where to find my key. Am I just pasting in the ssh file I have already saved on my folder, or is there a unique string within that file that I am needing to grab? If so - how do I find that? If not, what am I looking for here? Any help would be appreciated!! Sorry if this is a very elementary question. Thanks!!

Hopefully #error2007s helped but just in case -- you would need to put in your public key that is usually stored in a file called id_rsa.pub in your .ssh folder in your home directory. It starts with ssh-rsa, has a long list of letters and numbers and then ends with the email address you used when creating the key. You can list out the contents of that file by typing this in your terminal:
cat ~/.ssh/id_rsa.pub
That is what you need to add to the file on your server when you typed ~/.ssh/authorized_keys. Let me know if you have any other questions!

To be Direct to your question, on your blank nano editor for authorized_keys, you must put content of id_rsa.pub located under /home/deploy/.ssh/id_rsa.pub. you can simply cat /home/deploy/.ssh/id_rsa.pub, copy entire content and paste on the authorized_keys.
general steps to generate keys are below:
1) ls -ltr /home/deploy/.ssh - you would see like id_rsa, id_rsa.pub and authorized_keys. If you don't have authorized_keys, then do cp id_rsa.pub authorized_keys, it will copy id_rsa.pub content to authorized_keys. Please be sure that .ssh folder has 700 permission and files inside it has 600. Chmod 700 ~/ssh and Chmod 600 ~/ssh/*.
2) Create a key file in your local computer like (nano mydeploykey.pem) and make sure you copy the entire content of id_rsa and paste it on mydeploy.pem. Please ensure -----BEGIN RSA PRIVATE KEY----- contents and -----END RSA PRIVATE KEY----- is present. Note that there are five (5) dashes ----- and make sure you have those in your keys. If you missed copying one dash, it will not work.
Alternatively, you can use winscp or filezilla to copy id_rsa to your local computer and rename it as mydeploykey.pem. this key (mydeploykey.pem) should have 600 permission as well, if its too open, it will complain.
if you are using terminal to login, please use the following command.
ssh -i /path/to/mydeploykey.pem ubuntu#awspublicipaddress. Let me know if this does not work.

Related

Docker Github Load Key Invalid format

When using COPY to copy the private key into the Docker image, my image is able to connect to the github repo
COPY id_ed25519 /root/.ssh/id_ed25519
However, when I use the following, its now a wrong format.
RUN echo "${SSH_KEY}" > /root/.ssh/id_ed25519
I'm using Visual Code for developement, i've tried various ways of saving the key to the .env file
copy paste with mouse
copy paste with keyboard
leaving the end of the file SSH_KEY=" and running cat id_ed25519 > .env then adding a "
Sample .env
...
SOME_OTHER_VARL="http://localhost:3000"
# Github
SSH_KEY="-----BEGIN OPENSSH PRIVATE KEY-----
`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END OPENSSH PRIVATE KEY-----
"
Obviously something is happening to the format when I try to save the contents of the private key to the .env file. Anyone have any ideas?
Eventually this private key will end up in Azure Pipelines as a secrets, so I'll need a way to preserve the format there as well...
Thanks!

ruby on rails git permission denied

I am following this guide to set ruby on rails environment on my Mac El Captain.
I followed upto installing homebrew, ruby latest version 2.2.3 with rbenv. Now, I was setting up git.
Followed up first few commands
git config --global color.ui true
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR#EMAIL.com"
ssh-keygen -t rsa -C "YOUR#EMAIL.com"
Now, I have been asked to save the generated key. I saved it to ~ directory with a name file. I have now two files namely file and file.pub.
I went to this link to copy ssh key. I clicked on Add SSH key option there. Named the key ROR SSH Key.
The key in file.pub looks like
ssh-rss asfjasfhjalsfdhaskfdhalsdfsdf\asdf\as\dg\sa\fasdfas\f\asdf---so on random numbers---adfasdfasfa myemail#gmail.com
and I pasted the key there in github and saved the key.
Then, I went back to terminal and typed the below command.
ssh -T git#github.com
but I didn't received any message saying "Hi excid3! You've successfully authenticated, but GitHub does not provide shell access."
I got a message saying
The authenticity of host 'github.com (192.30.251.130)' can't be established.
RSA key fingerprint is SHA256:nThbg6sdfgdfgsdfgGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.251.130' (RSA) to the list of known hosts.
Permission denied (publickey).
Here above I have change few characters in SHA256 key. Just for security. Also, I have changed IP address a little bit for the same. But, the idea behind it is same.
Please guide me what's wrong. Thanks.
By default, ssh will look in the ~/.ssh folder for your private keys. Since you saved it in ~ instead, it can't find it.
You can either:
Move the file and file.pub files into ~/.ssh and rename to id_rsa and id_rsa.pub, as OS X will automatically use those files for any ssh command (if you hadn't manually entered a filename, this is where ssh-keygen would have saved them).
Use the ssh-add -K file command to permanently add your key to the OS X Keychain.
Note that GitHub's own instructions say they "strongly suggest keeping the default settings" instead of saving the private/public key somewhere else.

Net::SCP password prompt

Net::SCP requires password even though it is provided. Host machine has authorized_keys.pub and id_rsa.pub from user's machine.
User has id_rsa and id_rsa.pub
I also have tried to enter the ssh_key which was the preferred way of doing so from the start, still requires a pass.
The gist with the code is located at: https://gist.github.com/maimutza/fd45c16c220410a94420
You are using the incorrect name for your authorized_keys file.
Change authorized_keys.pub to authorized_keys

SCP didn't work in Jenkins

When I use the following codes in terminal, it works well.
#!/usr/bin/expect -f
spawn scp /Users/Shared/Jenkins/workspace/testslave/XXXXXX aaa#10.XXX.XXX.XX:/tmp/XXXX
expect "*assword:"
send "password\r"
interact
but when I copy the content to the Jenkins,the Jenkins didn't copy the file to the destination,and with no error.
A cleaner approach is to generate a public/private key with no pass-phrase and to use it as an authentication method.
The steps are:
Generate the key by executing ssh-keygen
Copy the public key (usually id_rsa.pub) to the .ssh folder of the user in the destination host. In your case it seems to be /Users/Shared/Jenkins/.ssh
Execute: scp -i id_rsa /Users/Shared/Jenkins/workspace/testslave/XXXXXX aaa#10.XXX.XXX.XX:/tmp/XXXX

Can’t SSH into my Digital Ocean droplet from Blink (iPadOS)

I am following this guide: https://thesweetsetup.com/how-to-use-digital-ocean-for-web-development-on-an-ipad/ To setup an environment on an iPad using Blink/Mosh.
I generated a droplet in the DO UI and added the public key I created using ssh-keygen in blink (also tried ssh-keygen -m pem). When I do ssh root#<IP-ADDRESS. I get the usual dialog:
Ed25519 key fingerprint is SHA256:<key>.
The server is unknown.
Do you trust the host key? (yes/no): yes
This new key will be written on disk for further usage.
Do you agree? (yes/no): yes
After this I just get back to blink. If I try to SSH again nothing happens. If I try to say ssh -i id_rsa root#<IP-ADDRESS> also nothing happens.
What am I doing wrong? I found this: https://github.com/blinksh/blink/issues/725 But do not understand what to do to fix.
I had this same problem. The blink terminal didn't give me any output or anything. The problem is that you have to give the full path of the id_rsa file (from the perspective of your default blink directory). So instead of ssh -i id_rsa root#<IP-ADDRESS>, do ssh -i .ssh/id_rsa root#<IP-ADDRESS>.
Btw one difference in our ssh key creation is that you created your key with the command ssh-keygen -m pem while I used ssh-keygen -t rsa -b 4096. I don't think that should be a problem though.
I had this same issue on some DO droplets I had. I had already set up the droplets with another key and added a new one for my blink app through the DO interface with no luck.
Realized that I had to still add the new public key to the authorized keys file in your users .ssh directory. ( ~/.ssh/authorized_keys ) and this solved my problem.
I did this through the device I was already using successfully, and copied to new key to that device to paste in.

Resources