Automatically login to you FTP account from Midnight Commander on a Mac (tip)
Some developers use Midnight Commander from Terminal on an Apple computer using OSX. People who use Midnight Commander will also use FTP client embedded into that program. With such use sometimes appear the need to automatically login to a FTP account from MC without entering username and password, and just by entering the host name.
There’s also a second case when our FTP username is with the following format: username@hostname. In that case we cannot enter in MC FTP client username@hostname@hostname.
To solve the problem we will create .netrc file that is used by Midnight Commander to store data for automatically login to FTP hosts, by providing only the host name.
So we will first open the OSX Terminal or iTerm2, then at command line we create .netrc file:
chmod 600 .netrc
chown myusername .netrc
where: myusername is your OSX username for your current OSX login
After that we will edit add the following line to .netrc (with: mcedit ~/.netrc):
machine example.com login email@example.com password mypassword
– machine is a required keyword
– login is a required keyword
– password is a required keyword
– example.com is your hostname, you must use your hostname here
– firstname.lastname@example.org, is your FTP username. If your FTP username is just username, delete @example.com
– mypassword is your FTP account password
After that run MC and go to F9 / Left / FTP link / Enter machine name and put there your hostname.
Now you should be able to login to your FTP server from Midnight Commander on OSX.