我可以在某个本地配置文件中为ftp服务器保存用户名/密码对,以便lftp在连接到该服务器时会自动找到它们吗?
背景:我有一些脚本,将由多个用户使用,具有不同的用户名/密码对,以将一些生成的内容从存储库同步到ftp服务器。 不必每次都手动输入我们的用户名/密码。 由于ftp密码是以明文形式发送的,因此我们都使用低值密码,因此将密码以明文形式存储在本地配置文件中是可以接受的。
Can I save a username/password pair for an ftp server in some local configuration file, so that lftp will find them automatically when connecting to that server?
Background: I have script which will be used by multiple users, with different username/password pairs, to sync some generated content from a repository to an ftp server. It would be nice not to have to enter our usernames/passwords by hand each time. Since ftp passwords are sent in cleartext, we are all using low-value passwords for this, so storing the passwords in cleartext in a local config file is acceptable.
最满意答案
您可以使用〜/ .netrc文件或lftp书签。
在〜/ .netrc中添加这样的东西:
machine your.server.example.com login your_login password your_password然后lftp会在打开ftp://your_login@your.server.example.com时选择密码,并且在没有URL语法的情况下打开“your.server.example.com”时会自动使用your_login 。
使用书签时,请执行“set bmk:save-passwords true” (默认为false),然后将当前会话保存到名称下的书签中, “open bookmark_name”将使用登录/密码对。 书签文件是纯文本,因此您甚至可以通过任何文本编辑器添加带有登录名/密码的URL。 要为所有用户使用通用书签,请将LFTP_HOME环境变量设置为公共目录。
You can use ~/.netrc file or lftp bookmarks.
Add something like this to ~/.netrc:
machine your.server.example.com login your_login password your_passwordThen lftp will pick the password when opening ftp://your_login@your.server.example.com, and it will use your_login automatically when opening "your.server.example.com" without the URL syntax.
When using bookmarks, do "set bmk:save-passwords true" (default is false), then save the current session to bookmarks under a name, then "open bookmark_name" will use the login/password pair. The bookmarks file is plain text, so you can even add the URL with login/password by any text editor. To use a common bookmarks for all users set LFTP_HOME environment variable to a common directory.
更多推荐
发布评论