I'm using Powershell to write a sftp script using pscp from PuTTY to transfer files between windows machines. The issue is the Key Exchange algorithm options are not selectable from command line.
Command used:
D:\apps\PuTTY\pscp.exe -i $private_key_path ${from_path} ${username}@${host_name}:${target_path}
$private_key_path = absolute path to private key
$from_path = path to local file
$username = username for host server
$host_name = host server name/ip
$target_path = host server filepath to save local file to
The following error occurs:
Fatal: Disconnected: Server protocol violation: unexpected SSH2_MSG_UNIMPLEMENTED packet
By following the instructions on this page PuTTY SSH2_MSG_UNIMPLEMENTED Error, basically you change the key auth algorithm hierarchy so the correct one is selected. Then I saved this session in PuTTY.
You can load a saved PuTTY session and I used the following command to successfully run file transfers:
D:\apps\PuTTY\pscp.exe -load "SavedSession" $from_path $username@$host_name:$target_path
Now the question is: is there a way to do this without a saved PuTTY session? As in, is there a way to define the Key Exchange algorithm as part of the command?
It defaults to Diffie-Hellman group exchange, but I need it to be anything else. The host name might change as well as this script being migrated to different servers so change management for the PuTTY sessions between environments will be an issue.