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

Re: Private key works in GUI but not console

BD98037 wrote:

I got the same issue: Private key works in the GUI but not console. I'm attaching the screenshot. Would you please take a look and advise?

Please attach a complete log file both from GUI and script.
BD98037

Re: Private key works in GUI but not console

martin wrote:

Your command-line syntax is completely wrong.
Please read:
https://winscp.net/eng/docs/guide_automation



Hi,

I got the same issue: Private key works in the GUI but not console. I'm attaching the screenshot. Would you please take a look and advise?
patrussell87

Private key works in GUI but not console

I am trying to script a transfer using a private key. Everything works fine when using the GUI but the key does not authenticate when scripting the connection.
The private key is configured both in WinSCP and Pageant.

Here is my command line:
"c:\Program Files (x86)\WinSCP\WinSCP.exe"  "/console" "open USER@HOST.com" "-privatekey=G:\Documents\Key2.ppk"


And the resulting log file:
. 2014-04-04 08:08:48.370 --------------------------------------------------------------------------
. 2014-04-04 08:08:48.371 WinSCP Version 5.5.2 (Build 4130) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional)
. 2014-04-04 08:08:48.371 Configuration: HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\
. 2014-04-04 08:08:48.371 Local account: RENTECH\prussell
. 2014-04-04 08:08:48.371 Working directory: c:\
. 2014-04-04 08:08:48.371 Process ID: 9384
. 2014-04-04 08:08:48.371 Command-line: "c:\Program Files (x86)\WinSCP\WinSCP.exe" "/console" "open USER@HOST.com" "-privatekey=G:\Documents\Key2.ppk"
. 2014-04-04 08:08:48.371 Time zone: Current: GMT-5, Standard: GMT-6 (Central Standard Time), DST: GMT-5 (Central Daylight Time), DST Start: 3/9/2014, DST End: 11/2/2014
. 2014-04-04 08:08:48.371 Login time: Friday, April 04, 2014 8:08:48 AM
. 2014-04-04 08:08:48.372 --------------------------------------------------------------------------
. 2014-04-04 08:08:48.372 Script: Retrospectivelly logging previous script records:
< 2014-04-04 08:08:48.372 Script: Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead.
. 2014-04-04 08:08:48.372 --------------------------------------------------------------------------
. 2014-04-04 08:08:48.372 Session name: open USER@HOST.com (Modified site)
. 2014-04-04 08:08:48.372 Host name: HOST.com (Port: 22)
. 2014-04-04 08:08:48.372 User name: open USER (Password: No, Key file: Yes)
. 2014-04-04 08:08:48.372 Tunnel: No
. 2014-04-04 08:08:48.372 Transfer Protocol: SFTP (SCP)
. 2014-04-04 08:08:48.372 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2014-04-04 08:08:48.372 Proxy: none
. 2014-04-04 08:08:48.372 Send buffer: 262144
. 2014-04-04 08:08:48.372 SSH protocol version: 2; Compression: No
. 2014-04-04 08:08:48.372 Bypass authentication: No
. 2014-04-04 08:08:48.372 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2014-04-04 08:08:48.372 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2014-04-04 08:08:48.372 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2014-04-04 08:08:48.372 Simple channel: Yes
. 2014-04-04 08:08:48.372 Return code variable: Autodetect; Lookup user groups: A
. 2014-04-04 08:08:48.372 Shell: default
. 2014-04-04 08:08:48.372 EOL: 0, UTF: 2
. 2014-04-04 08:08:48.372 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2014-04-04 08:08:48.372 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2014-04-04 08:08:48.372 SFTP Bugs: A,A
. 2014-04-04 08:08:48.372 SFTP Server: default
. 2014-04-04 08:08:48.372 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2014-04-04 08:08:48.372 Cache directory changes: Yes, Permanent: Yes
. 2014-04-04 08:08:48.372 DST mode: 1; Timezone offset: 0h 0m
. 2014-04-04 08:08:48.372 --------------------------------------------------------------------------
. 2014-04-04 08:08:48.372 Looking up host "HOST.com"
. 2014-04-04 08:08:48.376 Connecting to xxx.xxx.xxx.xxx port 22
. 2014-04-04 08:08:48.465 Server version: SSH-2.0-OpenSSH_5.2
. 2014-04-04 08:08:48.465 Using SSH protocol version 2
. 2014-04-04 08:08:48.465 We claim version: SSH-2.0-WinSCP_release_5.5.2
. 2014-04-04 08:08:48.507 Doing Diffie-Hellman group exchange
. 2014-04-04 08:08:48.629 Doing Diffie-Hellman key exchange with hash SHA-256
. 2014-04-04 08:08:49.305 Verifying host key rsa2 XXXXXXXXXXXXXXXXXXX

with fingerprint ssh-rsa 1024 XXXXXXXXXXXXXXXXX
. 2014-04-04 08:08:49.305 Host key matches cached key
. 2014-04-04 08:08:49.305 Host key fingerprint is:
. 2014-04-04 08:08:49.305 ssh-rsa 1024 XXXXXXXXXXXXXXXXXXXXX
. 2014-04-04 08:08:49.305 Initialised AES-256 SDCTR client->server encryption
. 2014-04-04 08:08:49.305 Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-04-04 08:08:49.305 Initialised AES-256 SDCTR server->client encryption
. 2014-04-04 08:08:49.305 Initialised HMAC-SHA1 server->client MAC algorithm
. 2014-04-04 08:08:49.426 Reading private key file "G:\Documents\Loading\Key2.ppk"
. 2014-04-04 08:08:49.428 Pageant is running. Requesting keys.
. 2014-04-04 08:08:49.429 Pageant has 1 SSH-2 keys
. 2014-04-04 08:08:49.429 Pageant key #0 matches configured key file
! 2014-04-04 08:08:49.429 Using username "open USER".
. 2014-04-04 08:08:49.473 Trying Pageant key #0
. 2014-04-04 08:08:49.514 Server refused our key
. 2014-04-04 08:08:49.514 Attempting keyboard-interactive authentication
. 2014-04-04 08:08:49.557 Prompt (6, SSH server authentication, Using keyboard-interactive authentication., Password: )
. 2014-04-04 08:08:53.923 Disconnected: Unable to authenticate