Working fine with powershell and Posh-SSH. Powershell core should be supported
Import-Module "C:\tmp\Posh-SSH\3.0.8\Posh-SSH.psd1" # https://github.com/darkoperator/Posh-SSH/releases
# Connect with pubkey authentication, providing the Passphrase non-interactive, and accepting any remote pubkey
$sftpSession = New-SFTPSession -ComputerName example.com -Credential $keyFilePassphrase -KeyFile "C:\Path\To\private_key" -AcceptKey
# Write file to remote
Set-SFTPItem -SessionId $sftpSession.SessionID -Path C:\tmp\test.txt -Destination "/home/user/"
You could also use expect:
#!/usr/bin/expect
spawn scp user@host:/source user@host2:/target
expect "password"
send -- "$PASSWORD\n"
interact
Install expect and run the script
sudo apt install expect -y
chmod +x /usr/local/bin/update-file.exp
/usr/local/bin/update-file.exp