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?

2
  • Probably the network is not up yet. Nov 2, 2018 at 9:40
  • When SSH is used instead of HTTPS, it works though
    – d-_-b
    Nov 2, 2018 at 9:46

1 Answer 1

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 :)

2
  • Thank you for the suggestion. export HOME=/root did the trick.
    – d-_-b
    Nov 5, 2018 at 1:44
  • @d-_-b Great :) Care to accept the answer then? Thanks!
    – MLu
    Nov 5, 2018 at 2:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .