echo open sftp://username:password > C:\temp\temp.dat echo cd /cygdrive/c/pathToUse >> C:\temp\temp.dat echo put %USERDOMAIN%.ftp >> C:\temp\temp.dat echo put File1.txt File1.ftp >> C:\temp\temp.dat echo get File2.txt >> C:\temp\temp.dat echo get File3.txt >> C:\temp\temp.dat echo quit >> C:\temp\temp.dat echo exit >> C:\temp\temp.dat
I have a test Server/Client setup at my desk, so I tested using WinSCP for the first time to see whether it would connect by using the command -
And at first it said I needed a hostkey and WinSCP actually gave me the hostkey in the results. So I added the -hostkey "sshxxxxxxxxxx" switch at the end of first line in the .dat file and tried again to see if it would connect. It got further than before - no longer asking for the hostkey, but the results I got included:
"Server offered these authentication methods: publickey, gssapi-keyex,gssapi-with-mic"
Two questions: Since I won't know the hostkey on these 50 remote servers, how can I write the script to connect not knowing the hostkey?
If I am able to generate a hostkey for the initial SFTP connection, how do I authenticate with either publickey, gssapi-keyex, gssapi--with-mic?
And please be kind as this is my first time using WinSCP and trying to understand keygen and hostkey/publickey authentication.
I did find I can generate a public key if I use the command:
ssh-keygen -y -f ssh_host_rsa_key
in the correct directory. But I'm not sure how to utilize that within my batch script or WinSCP.