Operating System - HP-UX
1820879 Members
4232 Online
109628 Solutions
New Discussion юеВ

.netrc - multiple logins per machine possible?

 
SOLVED
Go to solution
Paul Ammirata
Occasional Contributor

.netrc - multiple logins per machine possible?

I want to populate the .netrc file for use with ftp autologin. However, I have need to ftp to a single remote host using several different login IDs. Is ftp autologin and .netrc compatible with this type of usage?
FTP autologin appears to search the .netrc file for the first occurence of the specified machine. I'm using ftp from within a shell script.
3 REPLIES 3
Jeff Schussele
Honored Contributor

Re: .netrc - multiple logins per machine possible?

Paul,

I don't believe so - check the following passage in the .netrc docs:

If the .netrc file contains password or account information for use other than for anonymous ftp, its owner must match the effective user ID of the current process. Its read, write, and execute mode bits for group and other must all be zero, and it must be readable by its owner. Otherwise, the file is ignored.

The link to this page is:

http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90682/B2355-90682_top.html&con=/hpux/onlinedocs/B2355-90682/00/03/305-con.html&toc=/hpux/onlinedocs/B2355-90682/00/03/305-toc.html&searchterms=.netrc&queryid=20020314-102527

I would suggest setting up .netrc files in all users needed & su to these users from within the script & then execute the ftp command.

HTH,
Jeff

PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Patrick Wallek
Honored Contributor
Solution

Re: .netrc - multiple logins per machine possible?

Here is what I just did to ftp to the same machine with different names:

1) modify /etc/hosts so that the same IP address has different name aliases. There can only be one name per line in this case, otherwise it won't work. For example:

1.2.3.4 machineA
1.2.3.4 machineB

2) Then I created the lines in .netrc like:

machineA login user_id1 passwd passwd1
machineB login user_id2 passwd passwd2

Then when if you do 'ftp machineA' it will pick up the line for machineA and if you 'ftp machineB' it will pick up the line for machineB, but since both have the same IP address in /etc/hosts, they will log into the same machine.
Jeff Schussele
Honored Contributor

Re: .netrc - multiple logins per machine possible?

That's pretty slick Patrick.
Worked for me too.
I can see where I misread the doc - as long as the owner of the .netrc file matches the ID of the process creator & no other perms are granted all will be fine.

I read more into that statement than was there. I thought the userID in the file had to match.

As usual - I learned something from your post.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!