简体   繁体   English

Windows 等效于 Unix 上的文件 .netrc?

[英]Windows equivalent of file .netrc on Unix?

On Unix, we can specify the ftp username/password in ~/.netrc file and next time onwards, there is no need to specify username/password while ftping to any machine provided the credentials for that machine exists in ~/.netrc file.在 Unix 上,我们可以在 ~/.netrc 文件中指定 ftp 用户名/密码,下次以后,如果该机器的凭据存在于 ~/.netrc 文件中,则无需指定用户名/密码。

It's very helpful especially if you need to login to multiple machines may times lets say for monitoring purposes.这非常有帮助,特别是如果您需要登录多台机器,可以说是出于监控目的。

Can any one please suggest if there is any equivalent of this on Windows?任何人都可以建议 Windows 上是否有任何等价物?

If you can get away from FTP and use SFTP instead, then you can use public key authentication and store your public key (found at ~/.ssh/id_rsa.pub ) on the server in ~/.ssh/authorized_keys .如果您可以摆脱 FTP 并改用 SFTP,那么您可以使用公钥身份验证并将您的公钥(位于~/.ssh/id_rsa.pub中)存储在服务器上的~/.ssh/authorized_keys中。

I'm not aware of Windows FTP client having a similar functionality to the UNIX .netrc file (although I've been wrong before, just ask the wife:-).我不知道 Windows FTP 客户端具有与 UNIX .netrc 文件类似的功能(虽然我之前错了,请问妻子:-)

I've always had my scripts store the user name and password in a secure file and constructed an equally secure command script on the fly, using the -n and -s option of ftp , such as:我一直让我的脚本将用户名和密码存储在一个安全文件中,并使用ftp-n-s选项即时构建一个同样安全的命令脚本,例如:

ftp -n -sgo.ftpcmds machine.com

and the go.ftpcmds contains (with suitable values of <username> and <password> ):并且 go.ftpcmds 包含(具有合适的<username><password>值):

user <username> <password>
ascii
get myfile.txt
quit

This allows me to automate all sorts of FTP tasks.这使我能够自动化各种 FTP 任务。 If you want to automate logging in for an interactive task, just leave off the quit at the end - it will leave you logged in.如果您想为交互式任务自动登录,只需在最后取消quit - 它会让您保持登录状态。

I'm not sure I understand your comment on using FTP to log in and monitor log files - surely you'd be logging in with telnet and its brethren rather than using FTP for that purpose.我不确定我是否理解您对使用 FTP 登录和监控日志文件的评论——您肯定会使用 telnet 及其兄弟登录,而不是为此目的使用 FTP。

This is a shortcoming of the FTP client that comes with Windows.这是Windows自带的FTP客户端的一个缺点。 There are plenty of other FTP clients for Windows that allow you to save your passwords. Windows 的许多其他 FTP 客户端允许您保存密码。

Windows uses _netrc in the %HOME% environment. Windows 在 %HOME% 环境中使用 _netrc。 Just change the file name from .netrc to _netrc.只需将文件名从 .netrc 更改为 _netrc。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM