'How to Git control code from a remote computer?
I have the following situation:
- I have a remote workstation (WS_A) in which I have code written. I write and execute the code in this workstation
- I access WS_A through SSH from my local Linux computer (loc_m). I also use Visual Studio code remote extension to directly code the code in the workstation. I transfer files from and to the WS_A using
scp - The worskation WS_A does not have access to the internet.
So I would like to do the following:
- Git manage my code: Simple enough, Git is installed in the workstation so no problem
- Keep a repository of this code in my local machine loc_m
- Keep a repository of this code in GitLab (or GitHub alternatively)
How can I do 2 and 3?
Solution 1:[1]
The worskation WS_A does not have access to the internet.
But you have SSH access to it, which means it does have access to the internet, ...provided you set up a reverse SSH tunnel.
- If
loc_mis Windows, installpxin order to set yourHTTP(S)_PROXYto localhost:3128 - if
loc_mis Linux, install a proxy like squid, again to set anHTTP_PROXYto localhost:3128.
Then, from loc_m:
ssh -R 3120:127.0.0.1:3128 -fNT -o IdentitiesOnly=yes -o PreferredAuthentications=publickey WS_A
With WS_A an entry in your ~/.ssh/config file:
Host WS_A
hostname ws.A.hostname
User rmeoteUser
IdentityFile ~/.ssh/key_for_WS_A
On WS_A, set HTTP_PROXY/HTTPS_PROXY to localhost:3120: that port will be redirected to your local machine, port 3128, which in turn has internet access.
From there, your remote code can be directly committed and pushed to GitHub/GitLab. No more scp back and forth.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
