tags:

views:

810

answers:

4

Hi,

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.

Its 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 in windows?

+3  A: 

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.

Ben Alpert
Definitely the way to go if your have the choice.
dmckee
If ssh is enabled,i can go for SFTP using Public key authentication.But the problem is that ssh is not enabled on all machines
Naga Kiran
+2  A: 

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.

paxdiablo
+1  A: 

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.

Greg Miller
I know many graphical based FTP clients allows you to save passwords in windows.But is there any command-line based ftp client in windows that remembers passwords as i need to issue the ftp commands from within the VIM editor.
Naga Kiran
If you can install Cygwin and use that, the .netrc should work just as it does on Linux.
Greg Miller
Good suggestion.Haven't thought about this and will give a try.
Naga Kiran
A: 

Hi Pax,

Can i do the same with sftp. I have some existing scripts which are using ftp + .netrc. I want to move on to sftp but it seems it doesn't support .netrc.

is there any other way?

will appreciate your help.

Thanks PS