Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to ftp using .netrc with multiple accounts

Tags:

linux

bash

ftp

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

like image 935
stratis Avatar asked Feb 16 '23 06:02

stratis


1 Answers

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
like image 65
David W. Avatar answered Feb 23 '23 19:02

David W.