16

In Midnight Commander one can make an SFTP connection to a remote machine using:

cd #sh:yourusername@example.com:/home/username/

How can this be done when the remote machine is using a non-standard port?

paradroid
  • 1,203

3 Answers3

17

Whenever you want to use non-default settings for ssh, define an alias in ~/.ssh/config. This way you can call ssh myalias, or have some application call ssh myalias under the hood, without having to worry as to how you're going to pass settings such as a non-default port, a different user name and so on.

Host foo
HostName example.com
Port 2222
User yourusername

Then in Midnight Commander: cd #sh:foo:

12

mc supports "Shell links" in the respective "side menu". This uses ssh to establish a fish connection (FIle transfer over SHell filesystem).

screenshot

mc help/man page:

help screenshot

AFAIK there is no equivalent to -J ssh option, when going through a jump server.

Other references

Pablo A
  • 2,712
  • It seems that I already knew about this, but didn't know of the name 'shell links', but how come # hash signs are used in the other answers, including mine? I cannot find any information on their use. – paradroid Nov 11 '17 at 00:43
  • 1
    As you probably know # are usually used for comments. On mc man page (FIle transfer over SHell filesystem section) use the hash sign but with a slash: /#sh:[user (slightly different from my screenshot). This is similar to an URI but I think it isn't (officially by IANA only exist fish and ssh schemes). – Pablo A Apr 28 '18 at 21:22
  • Do you know how reliable is FISH protocol? According to wikipedia, this seems to be designed mainly for mc: link. By reliability I mean can I trust the data transfer corruptions, etc. – KFL Dec 18 '21 at 00:33
  • @KFL If with reliable you mean secure, since it runs over ssh or rsh (see the added references) it should be as ssh/rsh could be. Check if you follow ssh best practices. – Pablo A Dec 18 '21 at 07:28
10

I realised that I had already tried the solution, but it did not work because I did not have sshd listening on the VPN interface I was using. I have now got the internal interface listening on the standard port, so I do not even need this solution any more, but here it is:

cd #sh:yourusername@example.com:[port]/home/username/
paradroid
  • 1,203