UnityAutoIncrementBuildVersion icon indicating copy to clipboard operation
UnityAutoIncrementBuildVersion copied to clipboard

SSH can't connect during cloud build

Open taktran opened this issue 8 years ago • 13 comments

I'm trying to run this on cloud build, and it seems like everything is set up with the keys (the code checks out fine, tests run and a build a created), however, when it tries to run the commit.sh, I get errors about Host key verification failed.. That seems to mean that the script can't get access to the key stored on cloud build.

To get the error, I ran:

ssh -T [email protected]
Host key verification failed.

How did you get it work?

taktran avatar Dec 08 '16 17:12 taktran

Hey, in the script, you should be able to set your ssh key that will be used with github. I'm gonna check this out for you today. This should be fine, given that it also clones with the same key. Maybe you just need to give it writing permissions in github?

PimDeWitte avatar Dec 08 '16 17:12 PimDeWitte

We have set the permissions in github to be read/write.

deploy-key

It seems really weird. I'm trying to find the ssh key it's using but it seems like ls -lav ~/.ssh is empty. I'm wondering if I have to add the key manually.

taktran avatar Dec 08 '16 18:12 taktran

Ok, so it seems the build process may have changed (another server clones the repo and then sends it off to the builder). I'm gonna have to figure out an easy way to do this, thinking about setting the key in the commit.sh file. Feel free to mess around with it - I probably won't get to it until end next week. Really sorry for the inconvenience.

PimDeWitte avatar Dec 09 '16 04:12 PimDeWitte

Okay, this should work:

  1. Generate a new key in the same directory as commit.sh called "deploy"
  2. Add the "deploy" key as a deploy key
  3. Update your commit.sh script with this one https://github.com/PimDeWitte/UnityAutoIncrementBuildVersion/blob/master/commit.sh

I haven't tested it yet, let me know if it works.

PimDeWitte avatar Dec 09 '16 07:12 PimDeWitte

Actually, before you do that, just add:

ssh-keyscan -H github.com >> ~/.ssh/known_hosts

to the commit.sh file and see if it works

PimDeWitte avatar Dec 09 '16 07:12 PimDeWitte

Nope, I tried just

ssh-keyscan -H github.com >> ~/.ssh/known_hosts

and I still get the error

6780: [Unity] Permission denied (publickey).
6781: [Unity] fatal: Could not read from remote repository.
6782: [Unity] Please make sure you have the correct access rights
6783: [Unity] and the repository exists.

Will try the other thing. Thanks!

taktran avatar Dec 09 '16 09:12 taktran

Oh, adding the deploy key into the repo (albeit private) is pretty risky. Don't think I want to do that.

Going to try and think of a better way...

taktran avatar Dec 09 '16 09:12 taktran

I've contacted cloud build support to see if they have any other solutions.

taktran avatar Dec 09 '16 10:12 taktran

Yeah that's probably a good idea. Let me know what they say.

PimDeWitte avatar Dec 09 '16 14:12 PimDeWitte

I'm gonna try to mess around with this:

https://gist.github.com/testcollab/1236348/8ebe7df22fef7e695b2835614aaeea0114a3477d

And just make cloud build it's own account

PimDeWitte avatar Dec 09 '16 14:12 PimDeWitte

It's been a while, but did you ever come up with a solution to this problem?

DecipherOne avatar Feb 16 '18 17:02 DecipherOne

I have the same problem even after I use known_hosts, have you found a solution for this?

irvifa avatar Apr 02 '19 02:04 irvifa

This is works for me, try to do:

chown $USER <path to known hosts>

irvifa avatar Apr 02 '19 04:04 irvifa