In this post, I show you how to configure SSH for Midnight Commander to remotely copy or move files with the file manager's Shell link feature and public key authentication. I will also explain the difference between files transferred over Shell Protocol (FISH) and Secure Copy Protocol (SCP) and say a word or two about Midnight Commander's SFTP feature.

Why use Midnight Commander for remote file transfers ^

Midnight Commander is one of the first tools I install on every Linux box. The nice thing about this file manager is that it allows you to connect remotely via SSH and SFTP easily to copy, move, view, or edit files on the remote machine.

Midnight Commander is a clone of Norton Commander, a file manager for MS-DOS that I have been using since long before Windows existed. Midnight Commander has an almost identical user interface because there was really not much to improve about Norton Commander.

If you are a Linux admin, you are used to working on a command line and might wonder why you would need a file manager with a GUI. While it is certainly a matter of taste, it is also often a matter of speed.

Copying or moving files with Midnight Commander is usually faster than the CLI if you have to skim a large number of files to decide which files you want to copy. My guess is that the tool's name stems from the fact that you can use it in the middle of the night without worrying about moving the wrong files due to a lack of concentration. In Midnight Commander, you can just select each file with CTRL+T and then copy or move it.

Another very useful feature is that if you want to view the contents of a file, you can simply hit F3. The file manager also allows you to remotely edit files using nano.

Because you can run Midnight Commander in a SSH terminal window, you can work with it on any Linux machine without a desktop environment, such as GNOME or KDE.

If you have to copy files to another server, you don't have to install anything on the remote system. On your local system, you just have to install Midnight Commander once with a simple one-liner (for instance, on Ubuntu):

sudo apt install mc

Files transferred over shell protocol (FISH) ^

When transferring files via SSH in Midnight Commander, you have to keep in mind that Midnight Commander uses FISH for remote shell connections, which does not require SCP to be installed on the remote system.

The main advantage over SCP on the command line is that you can also list the contents of the remote system, and the advantage over SFTP is that you don't have leave your shell and work on the SFTP console.

Connect to the remote host with SSH in Midnight Commander ^

I hope you have disabled password authentication for SSH on all your Linux machines. Just in case you are still working with passwords, you can simply connect to the remote system by clicking the Left or Right menu or, alternatively, pressing F9+L (or F9+R) and then selecting Shell link.

Shell link and SFTP link in Midnight Commander

Shell link and SFTP link in Midnight Commander

Then, as in SSH or SCP, you can connect to the remote system with this syntax:


Midnight Commander will then ask for the user password.

Connecting via SSH to a remote host in Midnight Commander

Connecting via SSH to a remote host in Midnight Commander

Configuring Shell link in Midnight Commander for public key authentication ^

In Midnight Commander, unlike in SSH or SCP, you cannot pass the identity file with the -i parameter for public key authentication. Thus, you have to store the SSH configuration in your config file. The file is located in your home directory in ~/.ssh/config.

If the file does not exist, you can just edit with the nano editor and then make sure that only your user has access to it:

chmod 600 config

The config file should contain the location of your private SSH key, the corresponding username, and the hostname. In addition, you can configure the port and the alias you want to use to save some typing (Host command).

Host yourHost
	Port 2222
	User ubuntu
	IdentityFile ~/.ssh/privatekey.key

In Midnight Commander, you then simply enter your alias after you select Shell link.

Using an alias for a Shell link

Using an alias for a Shell link

If you connect the first time to the remote host, you will have to confirm its authenticity.

Are you sure you want to continue connecting (yes/no/[fingerprint])?

If you prefer typing over clicking, you can connect to your remote host with this command:

cd sh://yourHost
Midnight Commander connected to a remote host

Midnight Commander connected to a remote host

Midnight Commander and SFTP link ^

You can also transfer files via SFTP in Midnight Commander. If you work on the command line, it makes a difference if you work with SCP or SFTP. With SCP, you can't list the contents of a directory; with SFTP, you have to use the old FTP console with its commands. Because you work in a GUI in Midnight Commander, it does not really make a difference which protocol you use.

However, it appears the SFTP implementation in Midnight Commander has a bug that has never been fixed. The SFTP link command ignores the SSH config file. This means you can't use public key authentication. Instead, you have to work with password authentication, which I don't recommend. So the best option is just to work with Shell link instead of SFTP link.

Troubleshooting ^

If you try to connect to a remote system where password authentication is disabled and public authentication is not configured properly, you will see fish: Waiting for initial line... on the console and then receive the following error message: Cannot chdir to "sh://user@host"

Midnight Commander fails to connect via SSH

Midnight Commander fails to connect via SSH

If you try to connect to the wrong port or wrong IP, you will only see fish: Waiting for initial line... and then the Midnight Commander UI will disappear and hang for some time.

To find out what went wrong, you can first use the ssh command to try to establish a connection. In most cases, you will notice that your SSH configuration is the culprit and not Midnight Commander. The error message you get with ssh will be more informative than the ones in Midnight Commander. Once you can connect via SSH, the Shell link feature will work as well.

  1. Samir 9 months ago

    I remember Norton Commander–wasn’t my cup of tea. We used this little known program call ‘The File Commander’ that never made it past v1.0. It was a superior program for file transfers though, very much like Midnight Commander is versus raw command line.

    • Author
      Michael Pietroforte 9 months ago

      Isn’t File Commander just another Norton Commander clone? And as far as I know, new versions are still released for Linux. You think File Commander is better than Midnight Commander?

      • Samir 7 months ago

        No, this was not even close to Norton Commander–it was far superior in every way. I never used a file program versus dos until we found The File Commander, but alas we had to abandon it after win3.1 because it didn’t support lfn.

        • Author
          Michael Pietroforte 7 months ago

          Yeah, maybe File Commander was better than Norton Commander, but how is the Linux version compared to Midnight Commander?

          • Samir 7 months ago

            There is no linux or any other version of The File Commander other than v1.00 for DOS so there is no way to compare with Midnight Commander that’s basically like Norton anyways. In terms of functionality, obviously Midnight can do more.

        • Author
          Michael Pietroforte 7 months ago

          File Commander is still maintained:

          • Samir 7 months ago

            That’s not The File Commander that we used. It was such a niche and small piece of software that I think I have the only copy left in the world since there’s no images or even references to it in search engines. And unfortunately that’s probably on some of my old Syquest 88/200 backups.

  2. Chris 7 months ago

    Nice Article so far but why using CTRL+T for file selection if the Insert-Key is faster?

    I remember times before Norton Commander was “born” and as I’ve started working with it, Commanders are my daily bread! 🙂

    • Author
      Michael Pietroforte 7 months ago

      Because Mac keyboards don’t have an insert key. I somehow always assume that all IT pros work on Macs these days. 😉

      • Samir 7 months ago

        Why would you assume that? What are the rest of us missing?

        • Author
          Michael Pietroforte 7 months ago

          You will never understand if you didn’t work on a Mac as an IT pro for a year or two. The reliability of macOS plus the fact that many great applications are not available for Windows were the main reason for me to switch.

          I’ve been a Windows MVP for 10 years and have managed Windows systems since version 1.0. So I can say I know both worlds well. The difference between Windows and macOS has become gigantic and the gap gets bigger with every Windows update.

          • Samir 7 months ago

            Sounds like the usual ‘Macs are better’ argument. I’ve dealt with Macs a few times when I didn’t have a windows PC to do something simple, and usually it was like pulling hen’s teeth unless I was in the command line and able to use something like ping or other unix commands. Otherwise, everything is completely non-intuitive to me.

            As far as reliability, I think my running and still functioning socket 478 pentium 4s prove that PCs can outlive macs any day as most old macs just can’t be used anymore without hacks. It’s probably also why apple discontinued their server line. Dell and HP dominate the data center and they run windows among other things, but none are running mac. So I would have to conclude that most IT pros are probably not working with macs–I know I don’t.

            • Author
              Michael Pietroforte 7 months ago

              I am not talking about the hardware. What many people don’t know is that Apple is essentially a software company, as far as I can see by far the best one on the planet. The hardware is a nice add-on, but not really a reason for switching to a Mac. Perhaps the M1 machines are a game changer here. We will see. For me the reason was the much better software. Since Nadella took over Windows is a mess.

              From experience I know it is pointless to discuss these things with people who don’t have substantial experience with Macs (no offense). I have been talking just like you before. In fact, I have been the fiercest Mac hater you can imagine. Read this to get an idea:

              • Samir 7 months ago

                The core unix under the mac is definitely solid and what turned the whole company around, no doubt about that. It’s so potent that there’s even been recent articles here on the Linux ‘addon’ for Windows. Windows is one of the few pieces of software left that are not unix based–and I see a time when it will move far away from its legacy (I think win11 makes a big step in that direction), that it too will be rewritten for unix.

                I still remember my uncle back in the 1990s telling me how unix was the way to go because the hardware didn’t matter any more. I didn’t get what he was saying back then–probably because I was only proficient in DOS at the time and was I think only 13. Fast forward to today, and he was dead on. And he’s done well learning all that ‘early on’ in modern computing. I think anyone that was a unix guru in the 1990s pretty much rules the world today, haha.

                For me it’s always been about UI and how fast can I get a job done from my standpoint as the user–I can care less that the computer will work on my command for the next 12hours, but my typing in the command in 3 seconds is all my time commitment is. And the birth of guis and ‘dummying down’ the interfaces has only slowed me down. And the mac is the worst of them, requiring the slowest most serial ui ever–the mouse. At least with the current crop of windows, you can still fly through most things with the keyboard if you know all the shortcuts. Very tough to do on a mac.

                I’ll definitely check out your article when I have more time. I always enjoy reading the posts here! 🙂 Thorough content about things that matter to us that work with this stuff every day. 🙂

Leave a reply

Your email address will not be published.


© 4sysops 2006 - 2022


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account