Using wget to download directories over FTP, but not passing the password as a parameter

拥有回忆 提交于 2019-12-11 12:30:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!