stratis
stratis

Reputation: 778

Connect to ftp using .netrc with multiple accounts

I have created a .netrc file so i can have some macros and automatically make some standard operations inside my ftp server.

The problem is that now every time i connect to this machine it always connects with the same account automatically ,without giving me the option to select an account for this machine.

I found this question inside stackoverflow,but seems that there is no answer that can help me.

Link to similar question

Thank you all in advance

Upvotes: 5

Views: 13974

Answers (2)

Kyle
Kyle

Reputation: 1

Simplest solution for me ( 2 accounts on same host ) was to add a made-up host name to the /etc/hosts file with the same IP address and then use that new hostname in the .netrc file.

Upvotes: 0

David W.
David W.

Reputation: 107040

In a .netrc file, each line referring to a particular machine looks like this:

machine booster    login baxter  password swordfish
machine wooster    login francis password sw0rdf1sh

This will define the logins for two machines: booster and wooster. If you put in a line like this:

default  login root  password secret

This will be used for any other machines you haven't already listed.

Macros can be defined for each machine, and are defined after the machine or default line. The macro is defined by the line macro followed by the macro name. If the name is init, that macro will be executed automatically by the system.

You need to define separate machine lines for each machine you are logging into, and then have a default line for all other machines (if so desired).

You can also tell ftp not to read in the .netrc file by doing one of the following:

$ ftp -n

You can also use another net resource file besides the default .netrc:

$ ftp -N my.netrc.file

Upvotes: 10

Related Questions