Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can git work via ssh port forwarding?

Tags:

git

ssh

My situation is, I can ssh to ComputerB (Code repos) where git repos is put. But my local connection is too slow to clone the code. And I can ssh to another machine (ComputerA) which is faster, so I want to clone the code through ComputerA.

This is what I did:

           ssh tunnel                           ssh tunnel
MyComputer ----------> ComputerA (I can ssh to) ----------> ComputerB (where the Code repos is and I can ssh to but too slow)

Using a command like this:

ssh -L1234:ComputerA_ip:22 Code_repos_ip

Then:

git clone git+ssh//localhost/repos local_repos (how can I assign the port 1234?)

If this doesn't work, what else can I do?

like image 782
okidogi Avatar asked Apr 09 '09 06:04

okidogi


People also ask

Does SSH support port forwarding?

SSH is a secure shell and it offers a private connection between hosts. SSH port forwarding is one method that is used to tunnel traffic through an SSH connection. This can be done either locally or remotely if you are not close by to the target machine. Port 22 is used by default for establishing SSH connections.

What does SSH forwarding allow?

Also known as dynamic tunneling, or SSH SOCKS5 proxy, dynamic port forwarding allows you to specify a connect port that will forward every incoming traffic to the remote server dynamically.

Can you SSH on port 443?

If you are able to SSH into [email protected] over port 443, you can override your SSH settings to force any connection to GitHub.com to run through that server and port.


2 Answers

Also, you can try to put port number in your ~/.ssh/config:

Host ComputerA
HostName localhost
Port 1234

And then use ComputerA in git clone command:

git clone git+ssh://ComputerA/repos local_repos
like image 148
Alexander Artemenko Avatar answered Sep 18 '22 04:09

Alexander Artemenko


How will going through two connections make your connection faster?

Anyhow, you should be able to do:

git clone git+ssh://localhost:1234/repos local_repos
like image 32
Brian Campbell Avatar answered Sep 18 '22 04:09

Brian Campbell