1

Issue I am trying to use git in /opt/jamf2snipe directory on an EC2 Instance. I have tried the following command: sudo git clone git@github.com:MYUSERNAME/jamf2snipe-school.git

It says connection timed out:

Cloning into 'jamf2snipe-school'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

If I try to run this in my home directory it works fine. It seems to be a permission issue with /opt. I am wary of changing permissions for /opt.

Setup

I am trying to do this on an Amazon EC2 Instance. Currently SSH is limited to certain IP addresses (not including Github). I followed this article from github to use SSH over HTTPS. I tested to make sure I had stuff setup correctly by using:

$ ssh -T git@github.com

received

Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.

I did this in /opt/jamf2snipe and the home directory successfully.

hdano99
  • 21
  • 3
  • `sudo git clone` vs `ssh -T git@github.com` — either use `sudo` both time or don't use `sudo` at all. – phd Sep 27 '22 at 17:24

1 Answers1

0

First, make sure to, if possible, not use sudo.
In addition of executing commands as root (which is dangerous), it uses its own environment variable, and SSH settings (in /root/.ssh), which differs from your normal EC2 user.

Conversely, making a repository in /opt, which might be accessible only by root, is not the best spot to clone a repository.

Second, Using SSH over the HTTPS port is the usual solution (like this one from 2018) on EC2, where the firewall can block by default SSH egress traffic.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250