...
- Set up a configuration file for your sftp connection. Call it "config" and put it in a folder called .ssh under your user folder (eg. c:\Users\{your name}\.ssh).
Sample file:
Code Block language bash Host sftp2aws HostName somehost.server.transfer.ca-central-1.amazonaws.com IdentityFile C:\Users\{your name}\Documents\sftpsmmstranscandsdsftp2aws-key User sftpaws HostKeyAlgorithms ssh-rsa Compression yes
- Host - alias name for your connection
- HostName - the actual destination of the sftp server
- IdentityFile - your private key
- User - usernameRest is likely optional
Create a script holding command(s) to actually send the file.
Sample script:Code Block put c:\yourfiletosend.txt exit
Run the sftp command:
Code Block C:\>sftp -b C:\sftpScript.txt sftp2aws
Here, the -b indicates you're running the sftp command in batch mode (ie. passing in a script) and sftp2aws is the connection you configured in your config file above.
You may have to add the server's identity to known_hosts (John Sewchand (Unlicensed))
NOTE:If this is the first time you are connecting to the sftp destination you may run into a problem because you don't explicitly trust the server's identity. You may get the following message:
Code Block Host key verification failed. Connection closed
The best way to add this trust is to run the following command on the command line and answer yes to the question Are you sure...:
Code Block C:\>ssh sftp2aws The authenticity of host 'somehost.server.transfer.ca-central-1.amazonaws.com (xx.xx.xxx.xxx)' can't be established. RSA key fingerprint is SHA256:blahblahblah. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'somehost.server.transfer.ca-central-1.amazonaws.com,xx.xx.xxx.xxx' (RSA) to the list of known hosts. Connection to somehost.server.transfer.ca-central-1.amazonaws.com closed by remote host. Connection to somehost.server.transfer.ca-central-1.amazonaws.com closed.
This will create the known_hosts file in your .ssh folder if it isn't already there, and it will add an entry for the destination. An entry in that file indicates the destination is trusted.