2

I am trying to git clone a private repository from GitHub on EC2 instance at launch.

What I have in my script(user data) is the following.

git clone -b branchname https://github.com/orgname/reponame.git /var/tmp/reponame

For some reason, this ends up

Cloning into '/var/tmp/reponame'...
fatal: could not read Username for 'https://github.com': No such device or address

but works fine when executed after launching the instance. (I have tested it right after the instance launch)

What would be the cause of this error?

d-_-b
  • 153
  • 1
  • 7

1 Answers1

2

You say it's a private repo - I guess that means it needs a username and password. How are you providing these?

If you have the credentials in e.g. /root/.git-credentials (as described here) and git clone still doesn't work it may be that $HOME isn't set in UserData script and therefore git doesn't find the credentials file.

Two options:

  • set HOME=/root before running git clone, or
  • save the .git-credentials file to / (as that's probably where is tries to find it when $HOME isn't set).

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86