Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

I do not know anything about "control m", so I cannot tell what's wrong. Though I'm pretty sure it is the same problem as with Windows Task Scheduler. Pageant should not be used for automation.
fawwazab

hi martin thanks for the reply and yes I read it and I don't see something applies to my issue as all of the steps were handled with the used for running the script but still the reason for me is unknown I really need a help on this issue and by the way I am using control m for automating running the script
martin

Re: Winscp Generated Powershell script not passing the Password for sftp connection login

How do you "automate running it"?

Did you read this FAQ?
https://winscp.net/eng/docs/faq_scheduler
fawwazab

Winscp Generated Powershell script not passing the Password for sftp connection login

dears greeting

I have a request to automate an sftp file transfer and I used the generate code facility to generate a powershell script as you can see below the issue is that the script works fine when I run it manually and after I added the PPK file and saved the passphrase using WinSCP Pageant but the same script not working when I automate running it, it stops when the passphrase required and as I said it is already saved in the WinSCP pageant on the same server.

script
& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul `
  /command `
    "open sftp://116_XXX_XXX:PASSWORD@mftuat.XXX.com/ -hostkey=`"`"ssh-rsa 1024 dz/EkPjAcHgvAwpKjAf6RCQ9+8hwPoiCKROEamN6Edw=`"`" -privatekey=`"`"D:\WinSCP\UAT_116_XXX_XXX.ppk`"`" -rawsettings ProxyMethod=3 ProxyHost=`"`"proxy.XXX.XXX`"`" ProxyPort=8080" `
    "put -delete C:\Simah\test1.txt /upload/TR/DATALOAD/" `
    "exit"
 
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}
 
exit $winscpResult


log :
. 2020-02-03 15:56:20.369 Leaving host lookup to proxy of "mftuat.XXX.com" (for SSH connection)

. 2020-02-03 15:56:20.369 Will use HTTP proxy at proxy.XXX.XXX:8080 to connect to mftuat.XXX.com:22
. 2020-02-03 15:56:20.369 Looking up host "proxy.XXX.XXX" for proxy
. 2020-02-03 15:56:20.369 Connecting to HTTP proxy at 10.XXX.XXX.10 port 8080
. 2020-02-03 15:56:20.369 Connecting to 10.XXX.XXX.10 port 8080
. 2020-02-03 15:56:20.369 We claim version: SSH-2.0-WinSCP_release_5.15.9
. 2020-02-03 15:56:20.447 Server version: SSH-2.0-InformaticaMFT10.2.2
. 2020-02-03 15:56:20.447 Using SSH protocol version 2
. 2020-02-03 15:56:20.447 Have a known host key of type rsa2
. 2020-02-03 15:56:20.463 Doing ECDH key exchange with curve nistp256 and hash SHA-256
. 2020-02-03 15:56:20.541 Server also has ssh-dss host key, but we don't know it
. 2020-02-03 15:56:20.541 Host key fingerprint is:
. 2020-02-03 15:56:20.541 ssh-rsa 1024 ab:46:60:59:73:66:50:cf:50:d2:d1:56:95:db:c9:c5 dz/EkPjAcHgvAwpKjAf6RCQ9+8hwPoiCKROEamN6Edw=
. 2020-02-03 15:56:20.541 Host key matches configured key
. 2020-02-03 15:56:20.541 Initialised AES-256 CBC client->server encryption
. 2020-02-03 15:56:20.541 Initialised HMAC-SHA1 client->server MAC algorithm
. 2020-02-03 15:56:20.557 Initialised AES-256 CBC server->client encryption
. 2020-02-03 15:56:20.557 Initialised HMAC-SHA1 server->client MAC algorithm
. 2020-02-03 15:56:20.588 Reading key file "D:\WinSCP\UAT_116_XXX_XXX.ppk"
! 2020-02-03 15:56:20.588 Using username "116_XXX_XXX".
. 2020-02-03 15:56:20.760 Server offered these authentication methods: password,publickey,keyboard-interactive
. 2020-02-03 15:56:20.760 Offered public key
. 2020-02-03 15:56:20.791 Offer of public key accepted
! 2020-02-03 15:56:20.791 Authenticating with public key "imported-openssh-key"
. 2020-02-03 15:56:20.791 Prompt (passphrase, "SSH key passphrase", <no instructions>, "Passphrase for key "imported-openssh-key": ")
! 2020-02-03 15:56:30.869 Wrong passphrase
. 2020-02-03 15:56:30.869 Prompt (passphrase, "SSH key passphrase", <no instructions>, "Passphrase for key "imported-openssh-key": ")
. 2020-02-03 15:56:40.963 Authentication failed.
Error