git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to pass ssh options to git?

From
Shawn Pearce <spearce@spearce.org>
Date
Nov 2, 2006, 20:22 UTC
Message-ID
<20061102202230.GA21456@spearce.org>
In-Reply-To
<Pine.LNX.4.64.0611020801160.25218@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> wrote:
Show 14 quoted lines
> It's really better to use a ".ssh/config" file instead.
> 
> I realize that you want to use different options "dynamically", but what 
> you can do is to just have different "fake hostnames". For example, you 
> can do
> 
> 	Host private.host.com
> 		User myname
> 		Hostname host.com
> 		IdentityFile /home/myname/.ssh/private-identity
> 	Host public.host.com
> 		User groupname
> 		Hostname host.com
> 		IdentityFile /home/myname/.ssh/public-identity

I often setup not only multiple fake hostnames in my .ssh/config but I also setup multiple remote files under any given repository's .git/remotes directory, using one file per fake hostname.

That way I can pick which options to apply at the time of git push or git fetch by just changing the name passed to it.

	$ ls .git/remotes
	private public
	$ cat .git/remotes/private
	URL: private.host.com:/path/to/repo
	Pull: refs/heads/master:refs/heads/origin
	$ cat .git/remotes/public
	URL: public.host.com:/path/to/repo
	Pull: refs/heads/master:refs/heads/origin
	$ git push private
	$ git fetch public

I often need this to traverse around firewalls and whatnot. It works pretty well, assuming I can remember where I'm currently connected to. :-)

Previous: Linus TorvaldsNext: Nicolas Vilz 'niv'
Message 7 of 8 in “how to pass ssh options to git?”
  1. Michael S. TsirkinNov 2, 2006
  2. Matthieu MoyNov 2, 2006
  3. Michael S. TsirkinNov 2, 2006
  4. Dennis StosbergNov 2, 2006
  5. Michael S. TsirkinNov 2, 2006
  6. Linus TorvaldsNov 2, 2006
  7. Shawn PearceNov 2, 2006
  8. Nicolas Vilz 'niv'Nov 2, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.