Git access fails in EC2 instance startup script (Ubuntu)Git Daemon on linux?Git and Amazon EC2 public key deniedHow to keep groups when pulling with gitUnable to do a git pull - related to upgrade from Ubuntu 11.10 to 12.04?Setup git on an Internal Server [Ubuntu]In Amazon EC2, what's the best way to clone a private github repository on boot?How to deploy in amazon ec2 through bitbucketEC2 instance (Ubuntu) suddenly got very sluggishAnsible can't git clone from enterprise git serverGit push fails in copied VM - stumped
Prime sieve in Python
How do I handle a table mixing up the DM and the players' roles too often?
Silly doubt about tidal effects and Einstein Field Equations
Trainee keeps missing deadlines for independent learning
Why are < or > required to use /dev/tcp
Can White Castle?
Is it illegal to withhold someone's passport and green card in California?
Can Ogre clerics use Purify Food and Drink on humanoid characters?
Do I have to explain the mechanical superiority of the player-character within the fiction of the game?
Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?
How large would a mega structure have to be to host 1 billion people indefinitely?
How much will studying magic in an academy cost?
Do I need a shock-proof watch for cycling?
What does it mean to "control target player"?
What's currently blocking the construction of the wall between Mexico and the US?
Did the CIA blow up a Siberian pipeline in 1982?
.NET executes a SQL query and Active Monitor shows multiple rows blocking each other
Parameterize chained calls to a utility program in Bash
Why don't countries like Japan just print more money?
How many children?
Cut the gold chain
Who are the remaining King/Queenslayers?
When can you leave off “le/la” to say “it” in French?
What's the difference between a deep fryer and a chip pan?
Git access fails in EC2 instance startup script (Ubuntu)
Git Daemon on linux?Git and Amazon EC2 public key deniedHow to keep groups when pulling with gitUnable to do a git pull - related to upgrade from Ubuntu 11.10 to 12.04?Setup git on an Internal Server [Ubuntu]In Amazon EC2, what's the best way to clone a private github repository on boot?How to deploy in amazon ec2 through bitbucketEC2 instance (Ubuntu) suddenly got very sluggishAnsible can't git clone from enterprise git serverGit push fails in copied VM - stumped
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am creating an ec2 instance from an AMI using
aws ec2 run-instances [lots of arguments] --user-data file://my_sh_file.sh
my_sh_file.sh looks like this:
su ubuntu # fails with or without this
cd /home/ubuntu/my_working_dir
git pull origin master
. app_startup_script.sh
Git is failing to connect with this error log (from /var/log/cloud-init-output.log):
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I log in myself (as ubuntu) and call git pull it works fine.
I guess that either (a) su ubuntu isn't working, or (b) (this seems less likely) that the ssh config isn't loaded at this point in the boot sequence... but I'm stumped. Help?
ubuntu amazon-web-services amazon-ec2 git
add a comment |
I am creating an ec2 instance from an AMI using
aws ec2 run-instances [lots of arguments] --user-data file://my_sh_file.sh
my_sh_file.sh looks like this:
su ubuntu # fails with or without this
cd /home/ubuntu/my_working_dir
git pull origin master
. app_startup_script.sh
Git is failing to connect with this error log (from /var/log/cloud-init-output.log):
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I log in myself (as ubuntu) and call git pull it works fine.
I guess that either (a) su ubuntu isn't working, or (b) (this seems less likely) that the ssh config isn't loaded at this point in the boot sequence... but I'm stumped. Help?
ubuntu amazon-web-services amazon-ec2 git
1
How are you cloning the git repo to begin with? That response suggests it may be an issue with the ssh key.
– Lucas Ramage
Jun 5 at 15:31
git remote -vplease. By the way, do you use ssh-agent?
– kubanczyk
Jun 5 at 18:00
I don't use ssh agent. Git remote: origin ec2-user@[ip of git server]:[repo name] (fetch) origin ec2-user@[ip of git server]:[repo name] (push) I agree it sounds like an access problem but when I log in myself and just call git pull origin master it works fine.
– Omroth
Jun 5 at 18:16
ssh key and config is in home/ubuntu/.ssh
– Omroth
Jun 5 at 18:17
add a comment |
I am creating an ec2 instance from an AMI using
aws ec2 run-instances [lots of arguments] --user-data file://my_sh_file.sh
my_sh_file.sh looks like this:
su ubuntu # fails with or without this
cd /home/ubuntu/my_working_dir
git pull origin master
. app_startup_script.sh
Git is failing to connect with this error log (from /var/log/cloud-init-output.log):
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I log in myself (as ubuntu) and call git pull it works fine.
I guess that either (a) su ubuntu isn't working, or (b) (this seems less likely) that the ssh config isn't loaded at this point in the boot sequence... but I'm stumped. Help?
ubuntu amazon-web-services amazon-ec2 git
I am creating an ec2 instance from an AMI using
aws ec2 run-instances [lots of arguments] --user-data file://my_sh_file.sh
my_sh_file.sh looks like this:
su ubuntu # fails with or without this
cd /home/ubuntu/my_working_dir
git pull origin master
. app_startup_script.sh
Git is failing to connect with this error log (from /var/log/cloud-init-output.log):
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I log in myself (as ubuntu) and call git pull it works fine.
I guess that either (a) su ubuntu isn't working, or (b) (this seems less likely) that the ssh config isn't loaded at this point in the boot sequence... but I'm stumped. Help?
ubuntu amazon-web-services amazon-ec2 git
ubuntu amazon-web-services amazon-ec2 git
edited Jun 5 at 18:21
Lucas Ramage
12310
12310
asked Jun 5 at 15:21
OmrothOmroth
354
354
1
How are you cloning the git repo to begin with? That response suggests it may be an issue with the ssh key.
– Lucas Ramage
Jun 5 at 15:31
git remote -vplease. By the way, do you use ssh-agent?
– kubanczyk
Jun 5 at 18:00
I don't use ssh agent. Git remote: origin ec2-user@[ip of git server]:[repo name] (fetch) origin ec2-user@[ip of git server]:[repo name] (push) I agree it sounds like an access problem but when I log in myself and just call git pull origin master it works fine.
– Omroth
Jun 5 at 18:16
ssh key and config is in home/ubuntu/.ssh
– Omroth
Jun 5 at 18:17
add a comment |
1
How are you cloning the git repo to begin with? That response suggests it may be an issue with the ssh key.
– Lucas Ramage
Jun 5 at 15:31
git remote -vplease. By the way, do you use ssh-agent?
– kubanczyk
Jun 5 at 18:00
I don't use ssh agent. Git remote: origin ec2-user@[ip of git server]:[repo name] (fetch) origin ec2-user@[ip of git server]:[repo name] (push) I agree it sounds like an access problem but when I log in myself and just call git pull origin master it works fine.
– Omroth
Jun 5 at 18:16
ssh key and config is in home/ubuntu/.ssh
– Omroth
Jun 5 at 18:17
1
1
How are you cloning the git repo to begin with? That response suggests it may be an issue with the ssh key.
– Lucas Ramage
Jun 5 at 15:31
How are you cloning the git repo to begin with? That response suggests it may be an issue with the ssh key.
– Lucas Ramage
Jun 5 at 15:31
git remote -v please. By the way, do you use ssh-agent?– kubanczyk
Jun 5 at 18:00
git remote -v please. By the way, do you use ssh-agent?– kubanczyk
Jun 5 at 18:00
I don't use ssh agent. Git remote: origin ec2-user@[ip of git server]:[repo name] (fetch) origin ec2-user@[ip of git server]:[repo name] (push) I agree it sounds like an access problem but when I log in myself and just call git pull origin master it works fine.
– Omroth
Jun 5 at 18:16
I don't use ssh agent. Git remote: origin ec2-user@[ip of git server]:[repo name] (fetch) origin ec2-user@[ip of git server]:[repo name] (push) I agree it sounds like an access problem but when I log in myself and just call git pull origin master it works fine.
– Omroth
Jun 5 at 18:16
ssh key and config is in home/ubuntu/.ssh
– Omroth
Jun 5 at 18:17
ssh key and config is in home/ubuntu/.ssh
– Omroth
Jun 5 at 18:17
add a comment |
1 Answer
1
active
oldest
votes
The way you use sudo Isn’t correct.
First of all it should be sudo -u ubuntu not just sudo ubuntu. However even then it wouldn't work.
When you run sudo it spawns a new shell or if a command is given it runs that command under the ubuntu user. In your case sudo -u ubuntu doesn’t have a command to run and because it is in non-interactive mode it won’t spawn a shell either. It simply exits.
The following lines - cd and git - then run in the context of the UserData script, not under ubuntu user, that's why it fails.
You can do this for example:
sudo -u ubuntu sh -c "cd /home/...; git pull ...; ./app.sh"
That will run all the commands under the ubuntu user.
Hope that helps :)
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f970244%2fgit-access-fails-in-ec2-instance-startup-script-ubuntu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The way you use sudo Isn’t correct.
First of all it should be sudo -u ubuntu not just sudo ubuntu. However even then it wouldn't work.
When you run sudo it spawns a new shell or if a command is given it runs that command under the ubuntu user. In your case sudo -u ubuntu doesn’t have a command to run and because it is in non-interactive mode it won’t spawn a shell either. It simply exits.
The following lines - cd and git - then run in the context of the UserData script, not under ubuntu user, that's why it fails.
You can do this for example:
sudo -u ubuntu sh -c "cd /home/...; git pull ...; ./app.sh"
That will run all the commands under the ubuntu user.
Hope that helps :)
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
add a comment |
The way you use sudo Isn’t correct.
First of all it should be sudo -u ubuntu not just sudo ubuntu. However even then it wouldn't work.
When you run sudo it spawns a new shell or if a command is given it runs that command under the ubuntu user. In your case sudo -u ubuntu doesn’t have a command to run and because it is in non-interactive mode it won’t spawn a shell either. It simply exits.
The following lines - cd and git - then run in the context of the UserData script, not under ubuntu user, that's why it fails.
You can do this for example:
sudo -u ubuntu sh -c "cd /home/...; git pull ...; ./app.sh"
That will run all the commands under the ubuntu user.
Hope that helps :)
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
add a comment |
The way you use sudo Isn’t correct.
First of all it should be sudo -u ubuntu not just sudo ubuntu. However even then it wouldn't work.
When you run sudo it spawns a new shell or if a command is given it runs that command under the ubuntu user. In your case sudo -u ubuntu doesn’t have a command to run and because it is in non-interactive mode it won’t spawn a shell either. It simply exits.
The following lines - cd and git - then run in the context of the UserData script, not under ubuntu user, that's why it fails.
You can do this for example:
sudo -u ubuntu sh -c "cd /home/...; git pull ...; ./app.sh"
That will run all the commands under the ubuntu user.
Hope that helps :)
The way you use sudo Isn’t correct.
First of all it should be sudo -u ubuntu not just sudo ubuntu. However even then it wouldn't work.
When you run sudo it spawns a new shell or if a command is given it runs that command under the ubuntu user. In your case sudo -u ubuntu doesn’t have a command to run and because it is in non-interactive mode it won’t spawn a shell either. It simply exits.
The following lines - cd and git - then run in the context of the UserData script, not under ubuntu user, that's why it fails.
You can do this for example:
sudo -u ubuntu sh -c "cd /home/...; git pull ...; ./app.sh"
That will run all the commands under the ubuntu user.
Hope that helps :)
edited Jun 5 at 22:11
answered Jun 5 at 20:53
MLuMLu
10.6k22546
10.6k22546
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
add a comment |
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
Thank you :) Perfect.
– Omroth
Jun 6 at 8:35
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f970244%2fgit-access-fails-in-ec2-instance-startup-script-ubuntu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
How are you cloning the git repo to begin with? That response suggests it may be an issue with the ssh key.
– Lucas Ramage
Jun 5 at 15:31
git remote -vplease. By the way, do you use ssh-agent?– kubanczyk
Jun 5 at 18:00
I don't use ssh agent. Git remote: origin ec2-user@[ip of git server]:[repo name] (fetch) origin ec2-user@[ip of git server]:[repo name] (push) I agree it sounds like an access problem but when I log in myself and just call git pull origin master it works fine.
– Omroth
Jun 5 at 18:16
ssh key and config is in home/ubuntu/.ssh
– Omroth
Jun 5 at 18:17