Known_hosts file not existing, can't do ssh in deployment

I’m trying to deploy an angular application dist folder to a server, but it appears that the .ssh directory does not exist in the deploy step of my project.

Does anyone know what I’m doing wrong? I’ve followed many topics from this forum but it still doesn’t seem to work.

My config file is here: https://github.com/wafffly/closetr/blob/master/.circleci/config.yml
Deploy Job logs are here: https://circleci.com/gh/wafffly/closetr/165

Please and Thank You

Try getting an SSH session into your failed build to see what is going on. The .ssh folder should have been created in your checkout step.

Hi halfer, I tried that but it seems like the .ssh folder only exists when I SSH into my failed build.

Alright, that is a bit strange. Try adding a mkdir -p ~/.ssh prior to the touch. It may also be worth swapping the tilde character for the exact path, in case $HOME is not set correctly.

Hi @JoshuaConcon, I agree with @halfer’s suggestion. It would be helpful to see what ~/.ssh resolves to when the failing command is run, and compare it to what it resolves to when you SSH into the job.

Hi Stella and halfer,

It seems to work now, but I’m running into a different issue with regards to ssh keys.

Here is my most recent build: https://circleci.com/gh/wafffly/closetr/193

I don’t see why it isn’t skipping the password prompt automatically after I added the ssh keys, is it maybe because the ssh-keyscan failed?

All the best

Try temporarily adding -vvv to your ssh command, to get a report on why it is falling back to password auth.

Just added it, I’m comparing it to the verbose logs for my own machine and it seems to not accept the key I put (I think). logs: https://circleci.com/gh/wafffly/closetr/195

I think this is the relevant error:

key_parse_private2: missing begin marker

Are you perhaps missing this in your key? There is an end one too.

-----BEGIN RSA PRIVATE KEY-----

Try pasting it again. Also, if you do have that, paste the key here (minus most of the contents of course). For example if it is not RSA it may fail - I seem to recall there are some new key formats that CircleCI has trouble with.

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAq2AKByG+U2eefVh+…
-----END RSA PRIVATE KEY-----

I seem to have the begin and end statements, what type of rsa keys is circleci compatible with? I feel like that should be in the documentation somewhere.

@JoshuaConcon Could you try regenerating a key with the command mentioned in this Support article? https://support.circleci.com/hc/en-us/articles/360021127693-How-to-generate-and-store-read-write-SSH-keys

1 Like

@stella I tried it and got this error:
ssh-keygen: illegal option -- m

If you are on an OS that does not support -m then I would guess other people would have encountered the same issue. I recommend searching for the error in a search engine, plus the name of your OS and the word “ssh-keygen”, to find related articles.