简体   繁体   中英

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.

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?

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 .

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:-).

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 -sgo.ftpcmds machine.com

and the go.ftpcmds contains (with suitable values of <username> and <password> ):

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

This allows me to automate all sorts of FTP tasks. 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.

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.

This is a shortcoming of the FTP client that comes with Windows. There are plenty of other FTP clients for Windows that allow you to save your passwords.

Windows uses _netrc in the %HOME% environment. Just change the file name from .netrc to _netrc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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