Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Theory</h1> <h2>General principles</h2> <p>Mercurial does work with aliases created in <code>~/.ssh/config</code> -- I use this feature all the time on Linux and OS X. This works because Mercurial doesn't try to resolve the hostname itself, but rather depends on SSH to do this (and passes the error up, when it encounters one). This is why the error is has the <code>ssh:</code> as part of its prefix. Bitbucket even has <a href="https://confluence.atlassian.com/pages/viewpage.action?pageId=271943168#ConfiguremultipleSSHidentitiesforGitBash%2CMacOSX%2C%26Linux-CreateaSSHconfigfile">help</a> on setting up aliases via <code>.ssh/config</code>. (In the linked example, they use it to manage two separate identities.) If you created an alias via another mechanism, say BASH <code>alias</code>, then this will not work because it is dependent on BASH, which Mercurial does not use.</p> <h2>From the Mercurial source code</h2> <p>I have also gone through the Mercurial source code for <code>clone</code>, including examining <code>sshpeer.py</code> and <code>util.py</code> for the SSH related parts, and Mercurial does indeed pass along the hostname/alias to SSH for correct parsing / interpretation. </p> <p>The docstring for <code>class url</code> in <code>util.py</code> of the Mercurial (2.6.3) source code:</p> <pre><code>Reliable URL parser. This parses URLs and provides attributes for the following components: &lt;scheme&gt;://&lt;user&gt;:&lt;passwd&gt;@&lt;host&gt;:&lt;port&gt;/&lt;path&gt;?&lt;query&gt;#&lt;fragment&gt; Missing components are set to None. The only exception is fragment, which is set to '' if present but empty. If parsefragment is False, fragment is included in query. If parsequery is False, query is included in path. If both are False, both fragment and query are included in path. See http://www.ietf.org/rfc/rfc2396.txt for more information. Note that for backward compatibility reasons, bundle URLs do not take host names. That means 'bundle://../' has a path of '../'. Examples: &gt;&gt;&gt; url('http://www.ietf.org/rfc/rfc2396.txt') &lt;url scheme: 'http', host: 'www.ietf.org', path: 'rfc/rfc2396.txt'&gt; &gt;&gt;&gt; url('ssh://[::1]:2200//home/joe/repo') &lt;url scheme: 'ssh', host: '[::1]', port: '2200', path: '/home/joe/repo'&gt; &gt;&gt;&gt; url('file:///home/joe/repo') &lt;url scheme: 'file', path: '/home/joe/repo'&gt; &gt;&gt;&gt; url('file:///c:/temp/foo/') &lt;url scheme: 'file', path: 'c:/temp/foo/'&gt; &gt;&gt;&gt; url('bundle:foo') &lt;url scheme: 'bundle', path: 'foo'&gt; &gt;&gt;&gt; url('bundle://../foo') &lt;url scheme: 'bundle', path: '../foo'&gt; &gt;&gt;&gt; url(r'c:\foo\bar') &lt;url path: 'c:\\foo\\bar'&gt; &gt;&gt;&gt; url(r'\\blah\blah\blah') &lt;url path: '\\\\blah\\blah\\blah'&gt; &gt;&gt;&gt; url(r'\\blah\blah\blah#baz') &lt;url path: '\\\\blah\\blah\\blah', fragment: 'baz'&gt; Authentication credentials: &gt;&gt;&gt; url('ssh://joe:xyz@x/repo') &lt;url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'&gt; &gt;&gt;&gt; url('ssh://joe@x/repo') &lt;url scheme: 'ssh', user: 'joe', host: 'x', path: 'repo'&gt; Query strings and fragments: &gt;&gt;&gt; url('http://host/a?b#c') &lt;url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'&gt; &gt;&gt;&gt; url('http://host/a?b#c', parsequery=False, parsefragment=False) &lt;url scheme: 'http', host: 'host', path: 'a?b#c'&gt; </code></pre> <p>However, the <code>__init__</code> method of <code>class sshpeer</code> in <code>sshpeer.py</code> (which is used for cloning over SSH) introduces the additional restriction that passwords are not allowed in the URL:</p> <pre><code> u = util.url(path, parsequery=False, parsefragment=False) if u.scheme != 'ssh' or not u.host or u.path is None: self._abort(error.RepoError(_("couldn't parse location %s") % path)) self.user = u.user if u.passwd is not None: self._abort(error.RepoError(_("password in URL not supported"))) </code></pre> <p>(Password in the URL is allowed for other protocols, but I'll leave finding the relevant blocks of code as an exercise for the reader, or see the documentation on <a href="http://www.selenic.com/mercurial/hg.1.html#urls">URLs</a>)</p> <h2>Demonstrating this live -- potential help in debugging</h2> <p>We can use the <code>-v</code> option to see exactly how Mercurial interacts with SSH during a clone. But first, some relevant excerpts from my configuration files.</p> <p>From my <code>.ssh/config</code> file:</p> <pre><code>Host bitbucket.ssh Hostname bitbucket.org User hg </code></pre> <p>From my <code>.hgrc</code> file: </p> <pre><code>[ui] # Irrelevant settings omitted # enable compression in SSH ssh = ssh -C </code></pre> <p>Now, we take a look at what happens during a clone:</p> <pre><code>livius@localhost ~ $ hg clone -v ssh://bitbucket.ssh/palday/splitauthor running ssh -C bitbucket.ssh 'hg -R palday/splitauthor serve --stdio' destination directory: splitauthor requesting all changes adding changesets adding manifests adding file changes added 3 changesets with 9 changes to 6 files updating to branch default resolving manifests getting .hgignore getting COPYING getting README.rst getting filter-revisions.awk getting splitauthor.sh getting testregex.sh 6 files updated, 0 files merged, 0 files removed, 0 files unresolved </code></pre> <p>The first output line really says it all: Mercurial passes the hostname that it parses out of the URL -- in this case, your alias -- to SSH, which handles the actual issue of resolving the hostname/alias. </p> <h1>Other Comments and Tips</h1> <ul> <li><p>In your example <code>hg clone ssh://myAlias.ssh//path/to/repo</code>, you have a slash too many after the hostname, but I'm assuming this is only in the example. If not, this could be causing your path to be absolute, instead of relative to a user name (as configured in <code>.ssh/config</code>). See also the examples in the documentation on <a href="http://www.selenic.com/mercurial/hg.1.html#clone"><code>hg clone</code></a></p></li> <li><p>I also find the exact error message a bit odd. When I try this with an undefined hostname, e.g. an alias that I haven't defined in my <code>.ssh/config</code>, I get the following error on OS X: <code>remote: ssh: Could not resolve hostname server.ssh: nodename nor servname provided, or not known</code>. On Linux, I get <code>remote: ssh: Could not resolve hostname server.ssh: Name or service not known</code>.</p> <p>So, my suspicion is that you're doing this on Windows. I don't know how PuTTY and the like handle the configuration file on Windows, which might mean that there's a different syntax and that's what your problem is. Running <code>hg clone -v</code> will also let you see the exact call Mercurial is making, which could also be quite useful in tracking down where things are going wrong. </p></li> <li><p>On the Unix-y systems, you can try <code>ssh -T myAlias.ssh</code> to test the connection and your alias pass/fail, or <code>ssh -v myAlias.ssh</code> to get exceptionally verbose output on what's happening during the connection. If <code>ssh -T</code> fails, then it's definitely an issue at a level lower than Mercurial.</p></li> <li><p>You can also set set SSH itself to be verbose: Instead of <code>ssh = ssh -C</code> like in my <code>.hgrc</code> snippet above, you can set <code>ssh = ssh -Cv</code> to get verbose debugging output from SSH. This generated about 70 lines of debugging output for me.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload