Need help with automating an upload to our SFTP site using WinSCP and a Batch File.

Advertisement

sherwinj
Guest

Need help with automating an upload to our SFTP site using WinSCP and a Batch File.

I have the following script in a Text File...if I run from a DOS Commandline
winscp.com /ini=nul /script=C:\admin\Faster\FasterScript2.txt

The File has the following info...

# Connect
open sftp://user:password@server.umich.edu/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..."
# Change remote directory
cd INBOUND
# Upload the file to current working directory
mput C:\admin\Faster\TestUpload.txt
# Disconnect
close
# Exit WinSCP
exit

I get a "If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection
press Cancel.(Y)es, (N)o, C(a)ncel, (C)opy Key:"

If I pres [Y] and [enter key] it works.

My Question is, how can I have the "If you trust...message" no longer be there?

Also, how can I get this in a Batch File, so I can schedule it as a Task??

Thank you in advance for your help!

Jody Sherwin
U of M
Email: sherwinj@umich.edu
Phone: 734-615-5644

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,070
Location:
Prague, Czechia

Re: Need help with automating an upload to our SFTP site using WinSCP and a Batch File.

You have to replace the ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx... placeholder with a real fingerprint of the host key.

WinSCP GUI can generate the code for you:
https://winscp.net/eng/docs/ui_generateurl#script

Reply with quote

Advertisement

You can post new topics in this forum