[ad_1]
Most of the answers given here do not explain the details for the most basic usage.
After you have setup a server (in this case a linux
server) in the cloud, you connect to it using ssh from the terminal.
From your computer, add the private key dyson-ubuntu-vm.pem
which is given to you by your cloud services provider such as Azure, AWS etc to your .ssh configuration on your local machine like this:
Copy the .pem
file to the /home/ssenyonjo/.ssh
folder, then open /home/ssenyonjo/.ssh/config
file and add the following entry:
Host 20.85.213.44
HostName 20.85.213.44
User Dyson
IdentityFile /home/ssenyonjo/.ssh/dyson-ubuntu-vm.pem
IdentitiesOnly yes
Now from your terminal, access the cloud linux server like so:
ssh [email protected]
When that works, create a git project on the cloud server like so:
[email protected]:~/projects$ git init --bare s2
Now come back to your local machine and clone that empty repository like so:
[email protected]:~/Projects/mastering-git$ git clone ssh://[email protected]/home/Dyson/projects/s2
If you see an error that looks something like: fatal: Could not read from remote repository
, It means you’re accessing the wrong folder. Ensure you have outlined the right path from the root to the created repository.
If you dont want to setup a config file but want to access the ssh server that requires a key, you can use below command:
GIT_SSH_COMMAND='ssh -i ~/Projects/aws/keys/aws_ubuntu.pem' git clone ssh://[email protected]/home/ubuntu/projects/mastering-git/rand
You can export the command to continue using it for other tasks like git push
and git pull
export GIT_SSH_COMMAND='ssh -i ~/Projects/aws/keys/aws_ubuntu.pem'
[ad_2]