Skip to content

June 28, 2012

Automatically login to you FTP account from Midnight Commander on a Mac (tip)

by noise

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:

cd ~
touch .netrc
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 username@example.com password mypassword

where:
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
username@example.com, 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.

Read more from OSX Tips

Leave a Reply

required
required

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments