0

I have two commands below that work when I use the command prompt but not in mobaxterm. Why?

ssh -L 16006:127.0.0.1:6006 [email protected]

works in command prompt and mobaxterm but

ssh -L 16006:127.0.0.1:6006 [email protected]

does not work only in mobaxterm. It gives me the message

_ssh: Could not resolve hostname 10.2.25: Name or service not known

2 Answers 2

2

It's not the same ssh.

In Bash inside MobaXterm ssh is aliased to /bin/ssh.exe which is a shell script which eventually runs /bin/_ssh.exe. These files were installed with MobaXterm. Outside MobaXterm they exist in %MyDocuments%\MobaXterm\slash\bin.

Your command prompt uses some other ssh.exe.

An IP address with only two dots is valid, still in practice some tools may disagree. And it's not the only possible cause to disagree, see this question about leading zeros.


To make both methods behave in the same way, you need to use the same ssh.exe each time.

  • Always use ssh from MobaXterm.

    Note even if you add %MyDocuments%\MobaXterm\slash\bin to your PATH in Windows, you won't be able to use ssh.exe from MobaXterm because it's not an executable Windows would understand. You can use _ssh.exe though: copy it to another location, rename to ssh.exe adjust PATH in Windows. This ssh will not support addresses like [email protected].

  • Or the other way around: always use the other ssh.

    • The simplest approach seems to redefine the ssh alias in Bash inside MobaXterm to point to ssh.exe used by your command prompt.

      alias ssh='/cygdrive/c/proper/path/ssh.exe'
      

      But note the original /bin/ssh.exe script is there for a reason. So maybe it's better to leave the original alias intact and to…

    • patch SSH_PROG="/bin/_ssh.exe" in the script and point to /cygdrive/c/proper/path/ssh.exe. The "new" ssh.exe may not be fully compatible with the script though. Future updates (if any) may revert the changes.

    Anyway in your case this ssh should support addresses like [email protected].

Even if you use the same ssh.exe but still rely on the script in one case, the results may not be strictly identical because the script does something extra.

-1

10.2.25 is an incomplete IP address, you're missing digits there. That's why the "hostname" doesn't get resolved

3
  • 1
    but i can ssh through command prompt no problem
    – Kong
    Commented Jun 15, 2020 at 12:05
  • only with the first command line, whjich is complete. The second one you listed has the target IP incomplete, hence the error with the hostname which can't be resolved
    – user705734
    Commented Jun 17, 2020 at 15:01
  • no i can ssh with both if using the command prompt.
    – Kong
    Commented Jun 17, 2020 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .