- Poll: How reliable are ChatGPT and Bing Chat? - Tue, May 23 2023
- Pip install Boto3 - Thu, Mar 24 2022
- Install Boto3 (AWS SDK for Python) in Visual Studio Code (VS Code) on Windows - Wed, Feb 23 2022
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.
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.
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 HostName 10.0.0.1 Port 2222 User ubuntu IdentityFile ~/.ssh/privatekey.key
In Midnight Commander, you then simply enter your alias after you select 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:
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.
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"
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.
Want to write for 4sysops? We are looking for new authors.
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.
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?
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.
Yeah, maybe File Commander was better than Norton Commander, but how is the Linux version compared to Midnight Commander?
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.
File Commander is still maintained: https://silk.apana.org.au/fc.html
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.
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! 🙂
Because Mac keyboards don’t have an insert key. I somehow always assume that all IT pros work on Macs these days. 😉
Why would you assume that? What are the rest of us missing?
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.
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.
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: https://4sysops.com/archives/why-i-dont-wanna-be-mac/
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. 🙂
I don’t think there is any excuse for using Apple software, not any more than Apple hardware. It’s still the same company that deliberately sabotages standards. If you want Unix, there is BSD, and well, who are we trying to fool – there is Linux. Why would you waste others’ (and your own) time dealing with Apple graphics, Apple deployment, Apple programming languages, Apple keyboards and all this madness created only to be different from the rest of the world? Don’t eradicate the whole IT community with that cancer, pretty please…
Standards are okay where they are really needed, but very dangerous where they are not needed. Standards are only possible if many companies agree on the standard. This is a problem because it limits competition as the slowest company determines the speed of change. It is extremely important for progress to have fierce competition between different ecosystems (Linux, Apple, Microsoft, etc.) with their own standards within their ecosystem. Standards are only needed where those ecosystems intersect (internet, peripherals, etc.) Standards in the wrong place eradicate progress.
And by the way, there is no such thing as an “IT community,” just as there is no community for car drivers, cat owners, smartphone users, and people with shoe size 10. A community is a group of people who know each other personally and interact in a meaningful way. People often misuse the term to justify their own ideology which in their view matches with the values of an abstract “community.”
Yeah no, Apple deliberately sabotages standards, that’s a bit different. Be it USB, keyboard, SDK, shell, graphics rendering, file formats, anything they touch really. This is not development, nobody profits from it.
> A community is a group of people who know each other personally
Not sure if this is dishonest or just the same rigged premises that make someone use and develop saboteur products in the first place… The term “information technology” gives it away that we “interact in a meaningful way” all the time, we do have common goals and interests. Those goals do not include feeding the greed of some new Jobs but to strive for better devices and content. This is what made Unix a great platform for several decades, and as usual, Apple only leeches on the effort on others while messing working things up. At least don’t make it a mindset.
What you call “sabotaging standards,” is setting standards for me. The rest of the industry often has to follow simply because Apple has the better engineers who think things through. Unlike Microsoft, Apple sets standards because they are obsessed with optimizing their products. Take USB Mini-B as an example. Apple didn’t use it on their phones because a plug where you first have to check the orientation is just very bad engineering. So the rest of the industry had to follow Apple and now we have USB-C.
However, my favorite example is when the “greedy” Linux company Google copied the new standard for phone UIs from the iPhone and built the Linux-based OS Android. Remember when Steve Jobs raged that he would go on thermonuclear war with Google because they adopted the Apple standard? I love it when “greedy” companies fight for standards because this means innovation and progress.
As to the “IT community,” what you do is very predictable. First you create the picture of a cozy family with common values by using the term “community.” Not surprisingly, these values happen to be identical with your own, private ideology which seems to be inspired by socialism. Next you create the picture of a “greedy” enemy of your “community” that we need to fight. Next we send the soldiers to defend our “community.” It is always the same.
In IT, we have this fruitless discussion since Bill Gates started a fight with the “computer community” who shamelessly copied his Altair BASIC. Since then people keep repeating the same arguments again and again without coming to any conclusion, just as the same dull dispute about capitalism vs. communism. Don’t you think this discussion is getting boring?
> So the rest of the industry had to follow Apple and now we have USB-C.
Apple still wouldn’t follow USB-C that the rest of the world does follow, mind you. Sounds a bit ironic that they apparently “set a standard” that only they don’t follow.
> my favorite example is when the “greedy” Linux company Google copied the new standard for phone UIs from the iPhone and built the Linux-based OS Android
Okay… this is not only whataboutism but some twisted interpretation of what a standard is. Copying a UI is not “following a standard” (neither is it a virtue really). User interactions may be based on conventions but it’s not the same as having to use different, Apple-exclusive tools because dalla dalla.
> As to the “IT community,” what you do is very predictable. First you create the picture of a cozy family with common values by using the term “community.” Not surprisingly, these values happen to be identical with your own, private ideology which seems to be inspired by socialism. Next you create the picture of a “greedy” enemy of your “community” that we need to fight. Next we send the soldiers to defend our “community.” It is always the same.
Okay, you really are the stereotypical Apple user who justifies being simply utterly selfish by some imagined fight against communism. In case you didn’t notice – you are the one who has been predicted. You are the one who voluntarily limited community to a “cozy family” because you cannot imagine that a community can be anything more than whatever you possess, control or have the most personal interests in.
Like no, if we remove your arbitrary limitation that only really fits the self-centered narrative, you can immediately see that developers, maintainers, manufacturers and even users have loads of common interest (as I have already pointed it out), and that common interest is not served by voluntaristic sabotage based on self-branding.
If you sit back and think about it for a while, it’s just ridiculous that you cite Google and Microsoft, companies with the biggest revenues around the globe, as companies backed up by communist ideology – also Apple, a company that started off from the theft of Jobs (and you clearly seem to think communism equals theft), as the bastion of capitalism under attack. Stop making everything that doesn’t remotely serve your personal benefit about capitalism and communism, take responsibility for your own decisions, because they DO affect others as well, whether you like it or not.
Of course, Apple supports USB-C. They co-developed it. Macs and iPads already have USB-C. The iPhone will probably get it too. The only thing that can happen is that the iPhone 15 won’t have any cable connections.
I don’t think that communism is theft. I think communism stands for failure, stagnation, poverty and suffering for the majority. I don’t think there is room for discussion here. This has been proved again and again.
And my personal responsibility is to buy as many Apple products as possible because I need to support this company, so they can continue to innovate. I forgot to mention that I also own Apple stocks. So it is fair to say that I earned more with Apple products than I paid for them. So yeah, it is all for my “personal benefit.” Feels great! Give it a try! 😉
> The iPhone will probably get it too. The only thing that can happen is that the iPhone 15 won’t have any cable connections.
After several years of near exclusive use in mobile device production, iPhone “will probably get” USB-C that Apple apparently co-developed. Just wow. So much for innovation. Good that you mention it – Apple also innovated removing chargers from the box and taking users’ choice to use a simple jack earphone.
> I don’t think that communism is theft. I think communism stands for failure, stagnation, poverty and suffering for the majority. I don’t think there is room for discussion here. This has been proved again and again.
Not sure how this is related to anything anybody has said, other than you converted legitimate criticism of Apple – because of their branding-oriented “innovation” that mostly means staying incompatible with everyone, solely to distinguish themselves and lock users into their ecosystem – into some superficial rant about communism and capitalism.
> I forgot to mention that I also own Apple stocks. So it is fair to say that I earned more with Apple products than I paid for them. So yeah, it is all for my “personal benefit.”
Well then, sorry for spoiling your little business here. Having said that, don’t you think it’s a bit… tasteless to spread plain Apple marketing gibberish under a post supposedly about Midnight Commander, which stands for everything Apple is NOT? Seems like once one associates with Apple, leeching on community effort becomes second nature.
Thanks for the article!
Any idea of any 3rd party GUI that supports SFTP/SCP and sudo? WinSCP does that, but nothing that I found so far for Mac… 🙁 I need to maintain 16 Linux hosts from Mac, and I can scp to each of those hosts as myself, but then need to sudo into another user. If I need to drop a few files into those 16 hosts under the sudo’ed username, it’s rather painful to do from the ad hoc command line… I think I will write some scripts for that, but I was really hoping for the same functionality as WinSCP and googling for it didn’t find anything similar so far. Any advise?
I am using Transmit. It is better than WinSCP in every aspect. The only feature Transmit really lacks is the sudo feature.
Another popular program for the Mac is Cyberduck. I am not sure if it is has this feature.
If it is only about single files, you can use the Mac’s built-in iTerm2 with shell integration. It allows you to upload files via scp by dropping the files right into your SSH terminal. The downside is that you first have to install shell integration on all your hosts. Iiterm2 is by far the best SSH client I have ever used.