ssh to compute engine keeps asking for a paraphrase - ssh

Just added a new machine on google cloud and ran the google config.
While I can successfully connect to the machine, any attempt to log in via ssh keeps prompting me for paraphrase. Even more, it happens on my other instances too.
Not sure why.
I tried:
eval "$(ssh-agent -s)"
ssh-add
But that made no difference.
Thoughts?

made a mistake with a private key (added the wrong one!).
Ran ssh-add ~/.ssh/google_compute_engine and problem was solved.

Related

Regularily loosing SSH connection rights on Hetzner Cloud

I have a strange issue regarding my setup login into my hetzner cloud via SSH.
initial situation
I have made a fresh SSH Key, added that to a fresh Hetzner Cloud solution and made the initial login into the cloud. I was able to access the cloud via terminal with the command ssh root#MY_IP
the issue
When I retry to access my server with ssh root#MY_IP a few days after I've made the setup, I get the following error message: root#MY_IP: Permission denied (publickey).
I haven't made any changes in the meantime, didn't to anything with the ssh connection, didn't created new ssh key, nothing. I don't understand why it just denies my connection try since it was working fine before.
Probably your ssh-agent was configured in a different shell?
Try listing your stored keys with
ssh-add -l
If you don't see the one you created for this specific machine/cluster, try adding it again with:
ssh-add <absolute_path_to_your_private_key>
If your agent is not even running, start it in the background with:
eval "$(ssh-agent -s)"

Cannot add ssh key to ~/.ssh permanently

I'm using the Vector Robot OSKR kit with Ubuntu 20.04. I have the public and private keys so I can ssh to Vector. The problem is that I cannot do an ssh-add to get the keys to stay permanently in ~/.ssh. I've tried:
ssh-add -K - this gives back a "could not open a connection to your authentication agent" error.
The only way everything works is if I do ssh-agent /bin/sh, get a new shell and then I can add the key and ssh to Vector. But that way does not seem permanent. I have to do it every time before every new SSH session. I have done chmod to the key, it just seems to not want to be a permanent addition to my .ssh folder. I've searched on here for a bit, and that's actually where I found out about the ssh-agent trick, but I'd really like to add this key so it's a permanent thing and I don't have to go through this process every time.
Ok, I think I have this. I opened a new session and it worked with no problem. Not sure what else was going on, but it works now. Most likely due to multitasking fat-fingering.

Cannot clone gitlab project via SSH

I am trying to use SSH method to clone gitlab project, and I follow the instructions in the website https://docs.gitlab.com/ee/ssh/ but it failed, below is the log that I run the command “ssh -Tvvv git#gitlab.com”, I have tried on several computers but the same problem happened. could anyone help me to figure out the problem, thanks!
enter image description here
Best Regards,
Simon
Make sure to answer yes at the "The authenticity of host 'gitlab.com' can't be established" step.
If you don't, the SSH connection won't complete, and the clone will fail.
That step should be asked only once, meaning your next ssh -Tvvv git#gitlab.com should not ask you again the same question, since ~/.known_hosts will have been updated.
This is safer than StrictHostKeyChecking=no.

GCE permission denied (publickey)

When I create a new instance in GCE I'm able to ssh to that new instance without an issue. gcutil checks to see if I have the keys (google_compute_engine) and if not, it will create them for me. It will then push the keys to the instance and will pause for five minutes to ensure the keys are placed there. Again, this all works smoothly on a new instance that I create. This also tells me that my ssh works.
However, when trying to connect to another instance that already exists using "gcutil --project= ssh ", it produces "Permission Denied (publickey). I removed the keys and re-ran the command and same error. The expected result would be like above - i.e create keys and push them to the instance. But this doesn't happen.
ssh -vvv has no useful info. /var/log/auth.log doesn't even show an attempted connection.
Anyone in GCE world/ssh have any idea why gcutil works so smoothly for one instance but not for the other? What should I check for debugging this?
Thanks in advance.
You might want to look at the answer to this question that explains how gcutil works. It covers a number of different scenarios at the end.

still asking for password even after setting up the machine for Password-less SSH Login

I need to copy a file from a remote machine to my local machine and I need to automate it.
I've tried SCP command and it's working, however, I could not automate the part wherein it is asking for the password of the user of the local machine and the remote machine.
Based on this article I can Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
after following all the instructions written there, I tried to access the remote machine using this
ssh lalala#XXX.XXX.XXX.XXX
it works, it doesnt ask for the password anymore. But when I tried copying a file from that machine using the command below,
scp lalala#XXX.XXX.XXX.XXX:'/a/b/c.txt' lelele#XXX.XXX.XXX.YYY:'/b/c/'
it still asks for the password of the localmachine which is the lelele#XXX.XXX.XXX.YYY
I wonder if I did something wrong? what could it be? is there something wrong with the format of the command?
BTW, im using Centos, and I'm planning to code it using python
If you are copying to your local machine why don't you just do
scp lalala#XXX.XXX.XXX.XXX:'/a/b/c.txt' /b/c/
?
I tried your line on some machine with similar setup and didn't get asked for password; I got an error instead, but this is probably due to differences in our configurations. I tried mine and it worked.
Regarding whether your connection succeeds in the remote machine you could tail this file there:
tail -f /var/log/secure
If you see no error there you can be sure (well, never say always) your layout with the generated keys is working.
In this case I bet you'll see no error there
I think you may have multiple ssh keys and set identies only as yes. If so, please check this answer: https://askubuntu.com/a/999306/398861