• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 937
  • Last Modified:

FTPerror.NETRC

I have a shell script that uses ftp to copy files from machine another machine

/sips @ ftp rs100
connect to rs100.xx.xx
220 rs100 FTP server ready
Error - .netrc file not correct mode
Remove password or correct mode
221 goodbye

Does this mean the .netrc file on server a has incorrect password.

I added a line for correct password for sips and i tried it manually and it works.

any idea.
0
sam15
Asked:
sam15
  • 3
  • 2
  • 2
3 Solutions
 
clayhopkinsCommented:
It probably means you either don't have access to read the source file, or write access on the destination folder.  Start by verifying that the ftp user or the usergroup that the ftp user belongs to has the correct permissions in both places.
0
 
simon3270Commented:
The .netrc file must only be readable and writable by the owner - not by group or other.

so

   chmod 600 ~/.netrc

and try again
0
 
sam15Author Commented:
kind of stange.

when i did chmod 600 it seems to run but i ran into other issues.

I had chmod 777 on the .netrc file, can this be an issue?

also i have 3 accounts in the .netrc file. which login does it read?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
clayhopkinsCommented:
chmod of 777 means anyone that can access your machine has full permissions (read, write, execute) on that file.  Not a good thing!  It should only be accessible by the file owner, hence the chmod of 600 as shown by simon.

Do you have three accounts listed under one machine name in the .netrc, or three machines each with their own user account?  There should only be one username/password pair per machine listed.
0
 
simon3270Commented:
Not only can anyone read and write your .netrc file (with 777 permissions), but the ftp program will ignore it.  It will *only* read that file and use the entries in it if the permissions are 600 (or 400 or 700, but 600 will do fine).
0
 
sam15Author Commented:
.netrc had two machines (one account for each).

then i added a second account (3rd line)  for 1st machine. Does this impact anything? would the program use the first line or 3rd line..

Are you also saying that the ftp program would not run with 777 permissions assigned. kind of strange. let us say i want all users or programs owned by others to run it.
0
 
simon3270Commented:
You can only have one account on each machine in .netrc - when you run the ftp program, it uses the supplied machine name to look up the single username and password to use.  If you have two accounts in .netrc for the same machine, the result may not be consistent or reliable.

Since ftp uses the exact hostname to look up the entry, it is possible to have two accounts on one machine if there is an alias available for that machine.  For example, if you are accessing a machine on your network and you can either use the bare hostname (e.g. ftpserv), or the hostname+domain (e.g. ftpserv.homedom.com), then you could have one entry in .netrc using ftpserv, and another for another account using ftpserv.homedom.com.  You then use the correct name for the account you want to access.

The .netrc file is specific to a single user (since it is in that user's home directory), and only that user can be allowed to read/write it.  If the file is readable or writable by anyone else (in the same group or not), then the ftp program will either ignore it (and prompt for username/password) or will, as in your case, stop.  

The permissions for the ftp program itself are separate.  They will probably be 755 or 555, so that anyone can execute the program, but only the owner can write to it (for 755) or nobody can write to for (555).  Having 777 permissions on the ftp program is very dangerous - it means that anyone can overwrite the program with a potentially dangerous new version.

So, on my local machine, I have:

$ ls -lL ~/.netrc /usr/bin/ftp
-rw------- 1 sr    sr     61 2011-02-04 15:23 /home/sr/.netrc
-rwxr-xr-x 1 root root 74123 2010-05-14 03:45 /usr/bin/ftp

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now