问题
When I don't have SSH access to a server, I usually download stuff over FTP, like this:
wget -r ftp://user:pass@server/path/to/dir
How do I keep my password more secure? I don't like that the password is in the command, but when I try something like this:
wget -r ftp://user@server/path/to/dir
it doesn't work. It gives me "Login incorrect".
回答1:
You can put your credentials in ~/.wgetrc like so:
ftp_user = user
ftp_password = pass
Depending on your needs, it is also possible to use a different location for this configuration file:
When initializing, Wget will look for a global startup file, /usr/local/etc/wgetrc by default (or some prefix other than /usr/local, if Wget was not installed there) and read commands from there, if it exists.
Then it will look for the user's file. If the environmental variable WGETRC is set, Wget will try to load that file. Failing that, no further attempts will be made.
If WGETRC is not set, Wget will try to load $HOME/.wgetrc.
回答2:
This also does the trick:
wget -r --ask-password ftp://user@server/path/to/dir
ask_password = on/off can also be declared in your ~/.wgetrc
.
来源:https://stackoverflow.com/questions/5277991/using-wget-to-download-directories-over-ftp-but-not-passing-the-password-as-a-p