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: GUI Session Log

Set

session.SessionLogPath = @"C:\path\winscp.log";
mageloff

Re: GUI Session Log

martin wrote:

OK, so it's indeed a two factor authentication.

Can you post a log file from the code (Session.SessionLogPath)?


I do not understand how to provide the log file... would you please provide me with an example for C#?
martin

Re: GUI Session Log

OK, so it's indeed a two factor authentication.

Can you post a log file from the code (Session.SessionLogPath)?
mageloff

GUI Session Log

Thank you again for all the help! Here is the Session Log from the GUI which is successful:

. 2015-10-28 11:55:20.073 --------------------------------------------------------------------------
. 2015-10-28 11:55:20.073 WinSCP Version 5.7.5 (Build 5665) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional)
. 2015-10-28 11:55:20.073 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2015-10-28 11:55:20.073 Log level: Normal
. 2015-10-28 11:55:20.073 Local account: Nick-TP\Nick
. 2015-10-28 11:55:20.074 Working directory: C:\Program Files (x86)\WinSCP
. 2015-10-28 11:55:20.074 Process ID: 11472
. 2015-10-28 11:55:20.074 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe"
. 2015-10-28 11:55:20.074 Time zone: Current: GMT-4, Standard: GMT-5 (Eastern Standard Time), DST: GMT-4 (Eastern Daylight Time), DST Start: 3/8/2015, DST End: 11/1/2015
. 2015-10-28 11:55:20.074 Login time: Wednesday, October 28, 2015 11:55:20 AM
. 2015-10-28 11:55:20.074 --------------------------------------------------------------------------
. 2015-10-28 11:55:20.074 Session name: TEST (Site)
. 2015-10-28 11:55:20.074 Host name: securedata.test.com (Port: 22)
. 2015-10-28 11:55:20.074 User name: Username (Password: Yes, Key file: Yes)
. 2015-10-28 11:55:20.074 Tunnel: No
. 2015-10-28 11:55:20.074 Transfer Protocol: SFTP (SCP)
. 2015-10-28 11:55:20.074 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2015-10-28 11:55:20.074 Disable Nagle: No
. 2015-10-28 11:55:20.074 Proxy: none
. 2015-10-28 11:55:20.074 Send buffer: 262144
. 2015-10-28 11:55:20.074 SSH protocol version: 2; Compression: No
. 2015-10-28 11:55:20.074 Bypass authentication: No
. 2015-10-28 11:55:20.074 Try agent: Yes; Agent forwarding: Yes; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2015-10-28 11:55:20.074 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-10-28 11:55:20.074 KEX: dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,rsa,WARN
. 2015-10-28 11:55:20.074 SSH Bugs: A,A,A,A,A,A,A,A,A,A,A,A
. 2015-10-28 11:55:20.074 Simple channel: Yes
. 2015-10-28 11:55:20.074 Return code variable: Autodetect; Lookup user groups: A
. 2015-10-28 11:55:20.074 Shell: default
. 2015-10-28 11:55:20.075 EOL: 0, UTF: 2
. 2015-10-28 11:55:20.075 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-10-28 11:55:20.075 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-10-28 11:55:20.075 SFTP Bugs: A,A
. 2015-10-28 11:55:20.075 SFTP Server: default
. 2015-10-28 11:55:20.075 Local directory: C:\Users\Nick\Desktop, Remote directory: /ACH, Update: Yes, Cache: Yes
. 2015-10-28 11:55:20.075 Cache directory changes: Yes, Permanent: Yes
. 2015-10-28 11:55:20.075 DST mode: 1
. 2015-10-28 11:55:20.075 --------------------------------------------------------------------------
. 2015-10-28 11:55:20.154 Looking up host "securedata.test.com"
. 2015-10-28 11:55:20.161 Connecting to 205.205.106.103 port 22
. 2015-10-28 11:55:20.321 Server version: SSH-2.0-SSHD
. 2015-10-28 11:55:20.321 Using SSH protocol version 2
. 2015-10-28 11:55:20.321 We claim version: SSH-2.0-WinSCP_release_5.7.5
. 2015-10-28 11:55:20.394 Doing Diffie-Hellman group exchange
. 2015-10-28 11:55:20.586 Doing Diffie-Hellman key exchange with hash SHA-256
. 2015-10-28 11:55:20.842 Verifying host key rsa2 0x10001,0xa04a248fe05c3f48 bb58c888402a1ba0 d1be49698b9cc27a 1a5092aa94e627e0 -removed for security - with fingerprint ssh-rsa 2048 c1:82:96:44:-removed for security
. 2015-10-28 11:55:20.859 Host key matches cached key
. 2015-10-28 11:55:20.859 Host key fingerprint is:
. 2015-10-28 11:55:20.859 ssh-rsa 2048 c1:82:96:44:-removed for security
. 2015-10-28 11:55:20.859 Initialised AES-256 SDCTR client->server encryption
. 2015-10-28 11:55:20.859 Initialised HMAC-SHA1 client->server MAC algorithm
. 2015-10-28 11:55:20.859 Initialised AES-256 SDCTR server->client encryption
. 2015-10-28 11:55:20.859 Initialised HMAC-SHA1 server->client MAC algorithm
. 2015-10-28 11:55:21.048 Reading private key file "C:\Users\Nick\OneDrive\Documents\Business\Clients\CTU\ARS Development\ARS\ARS\Private_Key.ppk"
! 2015-10-28 11:55:21.049 Using username "AsapCruises".
. 2015-10-28 11:55:21.140 Offered public key
. 2015-10-28 11:55:21.318 Offer of public key accepted
! 2015-10-28 11:55:21.318 Authenticating with public key "imported-openssh-key"
. 2015-10-28 11:55:21.670 Sent public key signature
! 2015-10-28 11:55:21.744 Further authentication required
. 2015-10-28 11:55:21.780 Further authentication required
. 2015-10-28 11:55:21.780 Attempting keyboard-interactive authentication
. 2015-10-28 11:55:21.851 Prompt (keyboard interactive, "SSH server: Password Authentication", "Using keyboard-interactive authentication.", "Password: ")
. 2015-10-28 11:55:21.851 Using stored password.
. 2015-10-28 11:55:21.980 Access granted
. 2015-10-28 11:55:21.980 Opening session as main channel
. 2015-10-28 11:55:22.054 Opened main channel
. 2015-10-28 11:55:22.340 Started a shell/command
. 2015-10-28 11:55:22.386 --------------------------------------------------------------------------
. 2015-10-28 11:55:22.386 Using SFTP protocol.
. 2015-10-28 11:55:22.386 Doing startup conversation with host.
> 2015-10-28 11:55:22.439 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2015-10-28 11:55:22.511 Type: SSH_FXP_VERSION, Size: 33, Number: -1
. 2015-10-28 11:55:22.511 SFTP version 3 negotiated.
. 2015-10-28 11:55:22.511 Unknown server extension newline@vandyke.com="\n"
. 2015-10-28 11:55:22.512 We believe the server has signed timestamps bug
. 2015-10-28 11:55:22.512 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 string are not mandatory
. 2015-10-28 11:55:22.512 Changing directory to "/ACH".
. 2015-10-28 11:55:22.512 Getting real path for '/ACH'
> 2015-10-28 11:55:22.512 Type: SSH_FXP_REALPATH, Size: 13, Number: 16
< 2015-10-28 11:55:22.594 Type: SSH_FXP_NAME, Size: 49, Number: 16
. 2015-10-28 11:55:22.595 Real path is '/ACH'
. 2015-10-28 11:55:22.595 Trying to open directory "/ACH".
> 2015-10-28 11:55:22.595 Type: SSH_FXP_LSTAT, Size: 13, Number: 263
< 2015-10-28 11:55:22.679 Type: SSH_FXP_ATTRS, Size: 29, Number: 263
. 2015-10-28 11:55:22.679 Getting current directory name.
. 2015-10-28 11:55:22.845 Listing directory "/ACH".
> 2015-10-28 11:55:22.845 Type: SSH_FXP_OPENDIR, Size: 13, Number: 523
< 2015-10-28 11:55:22.939 Type: SSH_FXP_HANDLE, Size: 10, Number: 523
> 2015-10-28 11:55:22.939 Type: SSH_FXP_READDIR, Size: 10, Number: 780
< 2015-10-28 11:55:23.011 Type: SSH_FXP_NAME, Size: 316, Number: 780
> 2015-10-28 11:55:23.012 Type: SSH_FXP_READDIR, Size: 10, Number: 1036
< 2015-10-28 11:55:23.089 Type: SSH_FXP_STATUS, Size: 17, Number: 1036
< 2015-10-28 11:55:23.089 Status code: 1
> 2015-10-28 11:55:23.089 Type: SSH_FXP_CLOSE, Size: 10, Number: 1284
. 2015-10-28 11:55:23.089 ..;d;0;2015-10-20T12:54:00.000Z;"7020" [7020];"7014" [7014];rwxr-xr-x;0
. 2015-10-28 11:55:23.090 ROOT.TXT;-;26;2015-10-20T12:54:00.000Z;"7020" [7020];"7014" [7014];rw-r--r--;0
. 2015-10-28 11:55:23.145 Startup conversation with host finished.
martin

Further authentication required

It looks like the server requires a two-factor authentication.

How do you authenticate in the GUI?
Can you show us a log of the GUI session?
mageloff

I have updated my code to:
SshPrivateKeyPath = Path.GetFullPath("Private_Key.ppk")

Now the error list I receive now is:
Authenticating with public key "imported-openssh-key",
Further authentication required
Acess denied.
Authenication failed.

I have also placed WinSCP.exe in the same folder as my application and part of my c# project.

What I am missing or doing wrong?

Many, many thanks!
Nick
martin

Re: SshPrivateKeyPath Usage

The relative paths are resolved relatively to the location of winscp.exe (which may not be the same location as your application).

Better use an absolute path.

Path.GetFullPath("Private_Key.ppk")
mageloff

SshPrivateKeyPath Usage

Greetings,

I can successfully connect SFTP using the WinSCP GUI

I also did confirm that my Private Key file is in the same folder as my application.

When I attempt to connect via c# I use the following code

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "securedata.test.com",
UserName = "TestUser",
Password = "Password123",
PortNumber = 22,
SshHostKeyFingerprint = "ssh-rsa 2048 c1:28:69:44:c9:0e:c5:79:ce:8d:21:b1:bb:ba:5a:7c",
SshPrivateKeyPath = "Private_Key.ppk"
};

using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);

I receive the following error, see attached.

Thank you so much for you help!