Reputation: 212
I have setup an ssh connection on computer B and I am connecting to it properly via ssh. I want to execute a git pull
command so that it would pull the repo to computer A instead of B. Is that too much of a hassle or maybe is there an alternative?
I basically need to copy whatever git pull
pulled on computer B to my computer A. The only thing I have is just an ssh connection between the two and the repo is only reachable from computer B.
Upvotes: 3
Views: 2933
Reputation: 95101
It's possible to run git
commands over double ssh tunnel. The accepted answer there is a bit outdated, ssh
currently can construct a tunnel without external commands like netcat
or socat
.
Configure in your ~/.ssh/config
:
Host server
HostName git-server
ProxyCommand ssh -W %h:%p B
This configures ssh
to start a connection to the host B
and opens a
tunnel over that connection to the host git-server
. Run
git pull ssh://server/path/to/repository
Another possible solution is to use ext::
remote helper. See the second answer at the linked question. Run
git pull "ext::ssh -t B ssh git-server %S '/path/to/repository'"
Upvotes: 1
Reputation: 122
An other solution,(and the most straightforward solution in my opinion) is to just :
Upvotes: 1
Reputation: 1867
If I understand correctly, you want to use Git over an SSH tunnel so that computer A can access the repository REPO.git on computer C via computer B
On computer A, open the SSH tunnel:
ssh -L3333:compC:22 compB
From a second console on computer A:
git clone ssh://git@localhost:3333/REPO.git
Upvotes: 3
Reputation: 21
I'm not sure it will answer your question, but if it's only for pulling, you can use the scp command after pulling on B:
scp <source> <destination>
It will copy as the cp command but through your ssh connection.
Upvotes: 1