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 xyz@10.2.1.243

works in command prompt and mobaxterm but

ssh -L 16006:127.0.0.1:6006 xyz@10.2.25

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

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

Kong
  • 677

2 Answers2

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 xyz@10.2.25.

  • 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 xyz@10.2.25.

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

Dave M
  • 13,250