10

The following configuration works:

machine code.mycompany.net
login supernerd
password HelloW0rld

The following configuration doesn't work:

machine code.mycompany.net
login supernerd
password Please excuse my dear aunt sally.
Tom Norton
  • 751
  • 1
  • 8
  • 19

3 Answers3

5

From this bug report or this page, spaces in password don't seem to be supported in a .netrc (or _netrc) file.
Or even if they are, not all the programs using that .netrc file will be able to interpret said space correctly.


As runrig mentions in the comments:

Quoting the field as in another answer here should work, but the python library doesn't like it.
But, e.g., command line ftp and the perl netrc library is fine with it.

So this should work when used when those commands:

password "Please excuse my dear aunt sally."
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The man page doesn't mention spaces when used that way in a netrc file: http://linux.die.net/man/5/netrc – VonC Oct 01 '12 at 14:27
  • The python netrc library doesn't support spaces, but should. It's a bug in the library. Quoting the field as in another answer here should work, but the python library doesn't like it. But, e.g., command line ftp and the perl netrc library is fine with it. – runrig Feb 27 '15 at 18:10
4

Using ftp on IRIX 6.5 running on an SGI, I added quotes around my password and it works fine, e.g.:

password "Please excuse my dear aunt sally." 
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Jim
  • 41
  • 2
0

I have studied wget's netrc.c; I hope most netrc parsers work similarly:

Note that # after whitespace starts a comment until end of line.

A string can be put between double quotes (for example if the string starts with #, or contains a lot of whitespace that we don't want to backslash).

"#pass%"
"S3cret with spaces"

To make sure a character is understood as part of a string, prefix it with a backslash so that it is understood verbatim. This is supported with or without double quotes:

S3cret\ with\ spaces
\#not-a-comment
backslash:\\
"anything"
"double\"quote"
user1735594
  • 437
  • 1
  • 6
  • 9