Using Git, how can I add a remote from my local machine to a virtual machine (for hosting) that is only accessible from a secondary machine?
So to access this machine I would normally have to ssh into the first, then ssh into the second from the first one.
Is there a way to git remote add prod ssh://[email protected] > ssh://[email protected]/app-deployment.git
from my local machine?
Or will I have to set up another remote in the middle server with more hooks?
EDIT: The working repository is on my local machine, but the --bare repository I want to add as a remote is on "server2", there's no repository or code on server1, but I can only reach "server2" through ssh from "server1".
CodePudding user response:
Use server1
as an SSH jump host. On your local machine edit ~/.ssh/config
and add
Host server2
ProxyJump user1@server1
User user2
Test the configuration: from the local machine try
ssh server2
or
ssh user2@server2
If SSH successfully connects to server2
"directly" from your local machine (not really directly but automatically connecting to server1
and using it as a proxy) add it as a remote in Git repo:
git remote add prod ssh://user2@server2/repo.git
CodePudding user response:
try this:
git remote add origin <user>@<remote-server>:/absolute/path/to/repistory