Darcs push using SSH port forwarding
Some practical notes on how to push changes to darcs repos when no access to Internet is possible from the developer's computer, but there is another computer that has a global IP address.
- a developer's computer (actually, a virtual machine) with IP address 192.168.0.x which only has access to the local network
- a gateway computer which has local IP 192.168.0.1, and a global IP address, but does not provide any NAT to the 192.168.0.0 local network.
The gateway computer runs a HTTP proxy, so darcs pull can be done as usual, with curl.
The darcs repo "yyyy" to push into is located at http://darcs.haskell.org. To push changes from the developer's local repo, the following command is used:
darcs push --no-set-default firstname.lastname@example.org:/home/darcs/yyyy
where xxxx is the owner of the repo.
Since there is no IP forwarding from the local network to the Internet, the command above will not work. It is possible however to have ssh forward some local port to darcs.haskell.org's 22 port thus making it possible to establish ssh connection.
These commands will do:
ssh -L 2222:darcs.haskell.org:22 -f 192.168.0.1 sleep 1000 SSH_PORT=2222 darcs push --no-set-default xxxx@localhost:/home/darcs/yyyy
This repo requires public key authentication. The private key must be in the developer's .ssh directory.
The first command establishes connection forwarding. The port number 2222 is chosen arbitrarily. The second command uses 2222 (SSH_PORT) instead of standard 22, and connects to localhost using the same repo owner's username.
Timeout given to the sleep command should be large enough to cover the whole time of darcs transaction. After the timeout expires, background ssh terminates, and port forwarding is no longer available.