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

samv wrote:

> 2014-02-03 10:57:04.774 Script: open -hostkey="*" -timeout=15 "scp://sam@sftp.samtest.com "
...
. 2014-02-03 10:57:04.774 User name: sam (Password: No, Key file: No)

There's no private key specified. Are you sure that $scpPrivateKeyPath is set?
samv

Any Luck

Any Luck . Please note your profile does not have a email address specified
samv

. 2014-02-03 10:57:04.774 --------------------------------------------------------------------------
. 2014-02-03 10:57:04.774 WinSCP Version 5.5.0 (Build 3839) (OS 5.1.2600 Service Pack 3 - Microsoft Windows XP)
. 2014-02-03 10:57:04.774 Configuration: nul
. 2014-02-03 10:57:04.774 Local account: samcorp\sam
. 2014-02-03 10:57:04.774 Working directory: C:\Temp\BESUIMFeed\lib
. 2014-02-03 10:57:04.774 Process ID: 12068
. 2014-02-03 10:57:04.774 Command-line: "C:\Temp\BESUIMFeed\lib\winscp.exe" /xmllog="C:\Documents and Settings\sam\Local Settings\Temp\wscp07B8.03E87374.tmp" /xmlgroups /nointeractiveinput /dotnet=550 /ini=nul /log="C:\Temp\BESUIMFeed\log\session.log" /console /consoleinstance=_1976_3833263_418
. 2014-02-03 10:57:04.774 Time zone: Current: GMT-5, Standard: GMT-5, DST: GMT-4, DST Start: 3/9/2014, DST End: 11/2/2014
. 2014-02-03 10:57:04.774 Login time: Monday, February 03, 2014 10:57:04 AM
. 2014-02-03 10:57:04.774 --------------------------------------------------------------------------
. 2014-02-03 10:57:04.774 Script: Retrospectivelly logging previous script records:
> 2014-02-03 10:57:04.774 Script: option batch on
< 2014-02-03 10:57:04.774 Script: batch on
> 2014-02-03 10:57:04.774 Script: option confirm off
< 2014-02-03 10:57:04.774 Script: confirm off
> 2014-02-03 10:57:04.774 Script: open -hostkey="*" -timeout=15 "scp://sam@sftp.samtest.com "
. 2014-02-03 10:57:04.774 --------------------------------------------------------------------------
. 2014-02-03 10:57:04.774 Session name: sam@sftp.samtest.com (Ad-Hoc site)
. 2014-02-03 10:57:04.774 Host name: sftp.samtest.com (Port: 22)
. 2014-02-03 10:57:04.774 User name: sam (Password: No, Key file: No)
. 2014-02-03 10:57:04.774 Tunnel: No
. 2014-02-03 10:57:04.774 Transfer Protocol: SCP
. 2014-02-03 10:57:04.774 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2014-02-03 10:57:04.774 Proxy: none
. 2014-02-03 10:57:04.774 Send buffer: 262144
. 2014-02-03 10:57:04.774 SSH protocol version: 2; Compression: No
. 2014-02-03 10:57:04.774 Bypass authentication: No
. 2014-02-03 10:57:04.774 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2014-02-03 10:57:04.774 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2014-02-03 10:57:04.774 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2014-02-03 10:57:04.774 Simple channel: Yes
. 2014-02-03 10:57:04.774 Return code variable: Autodetect; Lookup user groups: A
. 2014-02-03 10:57:04.774 Shell: default
. 2014-02-03 10:57:04.774 EOL: 0, UTF: 2
. 2014-02-03 10:57:04.774 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2014-02-03 10:57:04.774 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2014-02-03 10:57:04.774 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2014-02-03 10:57:04.774 Cache directory changes: Yes, Permanent: Yes
. 2014-02-03 10:57:04.774 DST mode: 1; Timezone offset: 0h 0m
. 2014-02-03 10:57:04.774 --------------------------------------------------------------------------
. 2014-02-03 10:57:04.789 Looking up host "sftp.samtest.com"
. 2014-02-03 10:57:04.821 Connecting to 10.99.99.77 port 22
. 2014-02-03 10:57:04.836 Server version: SSH-2.0-OpenSSH_5.3
. 2014-02-03 10:57:04.836 Using SSH protocol version 2
. 2014-02-03 10:57:04.836 We claim version: SSH-2.0-WinSCP_release_5.5
. 2014-02-03 10:57:04.836 Doing Diffie-Hellman group exchange
. 2014-02-03 10:57:04.883 Doing Diffie-Hellman key exchange with hash SHA-256
. 2014-02-03 10:57:05.617 Verifying host key rsa2 xxxxxx with fingerprint ssh-rsa 1024 xx:xx:xx:Xx:xx
* 2014-02-03 10:57:05.617 WARNING! Giving up security and accepting any key as configured!
. 2014-02-03 10:57:05.617 Host key fingerprint is:
. 2014-02-03 10:57:05.617 ssh-rsa 1024 xx:xx:xx:Xx:xx
. 2014-02-03 10:57:05.617 Initialised AES-256 SDCTR client->server encryption
. 2014-02-03 10:57:05.617 Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-02-03 10:57:05.617 Initialised AES-256 SDCTR server->client encryption
. 2014-02-03 10:57:05.617 Initialised HMAC-SHA1 server->client MAC algorithm
! 2014-02-03 10:57:05.664 Using username "sam".
. 2014-02-03 10:57:05.664 Prompt (7, SSH password, , &Password: )
. 2014-02-03 10:57:05.664 Disconnected: Unable to authenticate
martin

Re: Error occurs when using Private key to authenticate

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
samv

guys, any ideas?
samv

Using pscp.exe
===============
C:\Temp\BESUIMFeed>c:\Downloads\putty\PScp.EXE -i "c:\Temp\SAMFeed\key\SAMPRIV.ppk" c:\temp\BESUIMFeed\archive\UseridList-SAM-BES-2014-01-16.csv sam@sftp.samtest.com:/apps/sam/infosec/data/bes/
UseridList-SAM-BES-201 | 5 kB | 5.8 kB/s | ETA: 00:00:00 | 100%


Using psftp to check the check on remote host after transfer.
==========================================================

C:\Temp\BESUIMFeed>c:\Downloads\putty\PSFTP.EXE -i "c:\Temp\SAMFeed\key\SAMPRIV.ppk" sam@sftp.samtest.com
Using username "sam".
******************************************************************

The use of this computer system is restricted to authorized Sam
Inc. Users for legitimate business purposes. Unauthorized access
or unauthorized attempted access is strictly prohibited and may be
subject to criminal prosecution.

******************************************************************

Remote working directory is /
psftp> cd /apps/sam/infosec/data/bes
Remote directory is now /apps/sam/infosec/data/bes
psftp> dir
Listing directory /apps/sam/infosec/data/bes
drwxrws--- 2 appuser appuser 3864 Jan 28 10:48 .
drwxrws--- 30 appuser appuser 3864 Jan 27 16:49 ..
-rw-rw---- 1 sam appuser 5951 Jan 28 10:48 UseridList-SAM-BES-2014-01-16.csv
psftp>
samv

Error occurs when using Private key to authenticate

Below is a function I've built in a Powershell script to scp file to a linux machine using Private key file.

Following is the error message generated by winscp

Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0."

I face no issues when using the same userid and Private key file with putty's psftp

function scpFile
{
logWrite("SCP'ing BES UIM file $BESUIMFeedFile to $sdxHost using id $sdxUser" )
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Scp
$sessionOptions.HostName = $sdxHost
$sessionOptions.UserName = $sdxUser
$sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey = $true
$sessionOptions.SshPrivateKeyPath = $scpPrivateKeyPath
$session = New-Object WinSCP.Session
try
{
#Connect
$session.Open($sessionOptions)
#
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult = $session.PutFiles($BESUIMFeedFile, $sdxDestPath, $False, $transferOptions)
# Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Transfers)
{
logWrite ("Upload of {0} succeeded" -f $transfer.FileName)
}
}
catch
{
writeToEventLog ($($Error[0]))
}
finally
{
$session.dispose()
}
}