Topic "Disconnected: Unable to authenticate"

Author Message
Viktoria
[View user's profile]

Joined: 2015-02-03
Posts: 2
Hi.

I want to connect to server with scp protocol and I can do this by WinScp.exe.
But c# code does not work =(

username = "root" and there's no password

Here's my code:

Code:


// Setup session options
var sessionOptions = new SessionOptions
{
    Protocol = Protocol.Scp,
    HostName = "10.0.6.10",
    UserName = "root",
    GiveUpSecurityAndAcceptAnySshHostKey = true,
};

using (var session = new Session()
        {
            SessionLogPath = Path.GetFullPath(@".\WinScpSessionLog.txt"),
            DebugLogPath =  Path.GetFullPath(@".\WinScpDebugLog.txt")
         })
{
    // Connect
    session.Open(sessionOptions);
}


Here is SessionLog
Code:

. 2015-02-03 11:50:25.854 --------------------------------------------------------------------------
. 2015-02-03 11:50:25.854 Script: Retrospectively logging previous script records:
> 2015-02-03 11:50:25.854 Script: option batch on
< 2015-02-03 11:50:25.854 Script: batch           on       
> 2015-02-03 11:50:25.854 Script: option confirm off
< 2015-02-03 11:50:25.854 Script: confirm         off       
> 2015-02-03 11:50:25.854 Script: open -hostkey="*" -timeout=15 "scp://root@10.0.6.10"
. 2015-02-03 11:50:25.854 --------------------------------------------------------------------------
. 2015-02-03 11:50:25.854 Session name: root@10.0.6.10 (Ad-Hoc site)
. 2015-02-03 11:50:25.854 Host name: 10.0.6.10 (Port: 22)
. 2015-02-03 11:50:25.854 User name: root (Password: No, Key file: No)
. 2015-02-03 11:50:25.854 Tunnel: No
. 2015-02-03 11:50:25.854 Transfer Protocol: SCP
. 2015-02-03 11:50:25.854 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2015-02-03 11:50:25.854 Proxy: none
. 2015-02-03 11:50:25.854 Send buffer: 262144
. 2015-02-03 11:50:25.854 SSH protocol version: 2; Compression: No
. 2015-02-03 11:50:25.854 Bypass authentication: No
. 2015-02-03 11:50:25.854 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2015-02-03 11:50:25.854 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-02-03 11:50:25.854 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2015-02-03 11:50:25.854 Simple channel: Yes
. 2015-02-03 11:50:25.854 Return code variable: Autodetect; Lookup user groups: A
. 2015-02-03 11:50:25.854 Shell: default
. 2015-02-03 11:50:25.854 EOL: 0, UTF: 2
. 2015-02-03 11:50:25.854 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-02-03 11:50:25.854 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-02-03 11:50:25.854 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2015-02-03 11:50:25.854 Cache directory changes: Yes, Permanent: Yes
. 2015-02-03 11:50:25.854 DST mode: 1; Timezone offset: 0h 0m
. 2015-02-03 11:50:25.855 --------------------------------------------------------------------------
. 2015-02-03 11:50:25.855 Looking up host "10.0.6.10"
. 2015-02-03 11:50:25.855 Connecting to 10.0.6.10 port 22
. 2015-02-03 11:50:25.877 Server version: SSH-2.0-dropbear_2012.55
. 2015-02-03 11:50:25.877 Using SSH protocol version 2
. 2015-02-03 11:50:25.877 We claim version: SSH-2.0-WinSCP_release_5.5.6
. 2015-02-03 11:50:25.882 Using Diffie-Hellman with standard group "group14"
. 2015-02-03 11:50:25.882 Doing Diffie-Hellman key exchange with hash SHA-1
. 2015-02-03 11:50:28.768 Verifying host key rsa2 0x10001,0xa7a19cd551c55d45 3d7bddcbe8e15343 b9d33bf2b647c3a2 9380a965ecb3b40f ed998cb4d2563515 062696665a1bbb6f d203e6fabaca4854 efaaddf00112b585 4dbfc27fde82b0f6 3b748cbfc0ccb0c1 761204ea860e9f92 01feba85cf57a17c f621203982649abb c0be6943518ad249 9ab7a757098f5c0a e26598411119fa6e 326f with fingerprint ssh-rsa 1040 7e:0c:fc:2d:0d:a9:36:b9:1f:c5:e1:12:29:5b:8e:3d
* 2015-02-03 11:50:28.769 WARNING! Giving up security and accepting any key as configured!
. 2015-02-03 11:50:28.769 Host key fingerprint is:
. 2015-02-03 11:50:28.769 ssh-rsa 1040 7e:0c:fc:2d:0d:a9:36:b9:1f:c5:e1:12:29:5b:8e:3d
. 2015-02-03 11:50:28.769 Initialised AES-256 SDCTR client->server encryption
. 2015-02-03 11:50:28.769 Initialised HMAC-SHA1 client->server MAC algorithm
. 2015-02-03 11:50:28.769 Initialised AES-256 SDCTR server->client encryption
. 2015-02-03 11:50:28.769 Initialised HMAC-SHA1 server->client MAC algorithm
! 2015-02-03 11:50:28.775 Using username "root".
. 2015-02-03 11:50:28.776 Prompt (7, SSH password, , &Password: )
. 2015-02-03 11:50:28.776 Disconnected: Unable to authenticate


I tried to set password as empty string in SessionOptions - does not work.

Please tell me how to connect with "root" and no password.
I say again - I can connect with WinScp.exe
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
So how do you authenticate in GUI? I assume you do not really allow root access with no authentication at all.

And I hope you really know, what you are doing, when using .GiveUpSecurityAndAcceptAnySshHostKey.
_________________
Martin Prikryl
Viktoria
[View user's profile]

Joined: 2015-02-03
Posts: 2
I have root access.

This is Log on connecting using GUI

Code:

. 2015-02-09 16:38:30.172 Session name: root@10.0.6.10 (Site)
. 2015-02-09 16:38:30.172 Host name: 10.0.6.10 (Port: 22)
. 2015-02-09 16:38:30.172 User name: root (Password: No, Key file: No)
. 2015-02-09 16:38:30.172 Tunnel: No
. 2015-02-09 16:38:30.172 Transfer Protocol: SCP
. 2015-02-09 16:38:30.172 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2015-02-09 16:38:30.172 Proxy: none
. 2015-02-09 16:38:30.172 Send buffer: 262144
. 2015-02-09 16:38:30.172 SSH protocol version: 2; Compression: No
. 2015-02-09 16:38:30.172 Bypass authentication: No
. 2015-02-09 16:38:30.172 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2015-02-09 16:38:30.172 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-02-09 16:38:30.172 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2015-02-09 16:38:30.172 Simple channel: Yes
. 2015-02-09 16:38:30.172 Return code variable: Autodetect; Lookup user groups: A
. 2015-02-09 16:38:30.172 Shell: default
. 2015-02-09 16:38:30.172 EOL: 0, UTF: 2
. 2015-02-09 16:38:30.172 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-02-09 16:38:30.172 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-02-09 16:38:30.172 Local directory: C:\Users\v.bakaldina.YAR\Documents, Remote directory: /mnt/ufs/root, Update: Yes, Cache: Yes
. 2015-02-09 16:38:30.172 Cache directory changes: Yes, Permanent: Yes
. 2015-02-09 16:38:30.172 DST mode: 1; Timezone offset: 0h 0m
. 2015-02-09 16:38:30.172 --------------------------------------------------------------------------
. 2015-02-09 16:38:30.243 Looking up host "10.0.6.10"
. 2015-02-09 16:38:30.243 Connecting to 10.0.6.10 port 22
. 2015-02-09 16:38:30.294 Server version: SSH-2.0-dropbear_2012.55
. 2015-02-09 16:38:30.294 Using SSH protocol version 2
. 2015-02-09 16:38:30.294 We claim version: SSH-2.0-WinSCP_release_5.5.6
. 2015-02-09 16:38:30.300 Using Diffie-Hellman with standard group "group14"
. 2015-02-09 16:38:30.300 Doing Diffie-Hellman key exchange with hash SHA-1
. 2015-02-09 16:38:33.200 Verifying host key rsa2 0x10001,0xa7a19cd551c55d45 3d7bddcbe8e15343 b9d33bf2b647c3a2 9380a965ecb3b40f ed998cb4d2563515 062696665a1bbb6f d203e6fabaca4854 efaaddf00112b585 4dbfc27fde82b0f6 3b748cbfc0ccb0c1 761204ea860e9f92 01feba85cf57a17c f621203982649abb c0be6943518ad249 9ab7a757098f5c0a e26598411119fa6e 326f with fingerprint ssh-rsa 1040 7e:0c:fc:2d:0d:a9:36:b9:1f:c5:e1:12:29:5b:8e:3d
. 2015-02-09 16:38:33.226 Host key matches cached key
. 2015-02-09 16:38:33.226 Host key fingerprint is:
. 2015-02-09 16:38:33.226 ssh-rsa 1040 7e:0c:fc:2d:0d:a9:36:b9:1f:c5:e1:12:29:5b:8e:3d
. 2015-02-09 16:38:33.226 Initialised AES-256 SDCTR client->server encryption
. 2015-02-09 16:38:33.226 Initialised HMAC-SHA1 client->server MAC algorithm
. 2015-02-09 16:38:33.226 Initialised AES-256 SDCTR server->client encryption
. 2015-02-09 16:38:33.226 Initialised HMAC-SHA1 server->client MAC algorithm
! 2015-02-09 16:38:33.239 Using username "root".
. 2015-02-09 16:38:33.279 Prompt (7, SSH password, , &Password: )
. 2015-02-09 16:38:34.918 Sent password
. 2015-02-09 16:38:34.960 Access granted
. 2015-02-09 16:38:34.960 Opening session as main channel
. 2015-02-09 16:38:34.967 Opened main channel
. 2015-02-09 16:38:36.031 Started a shell/command


The difference is that GUI asks for a password and I leave the password field empty, click on connect btn and connection happens
and I see file viewer.

GUI do this :
! 2015-02-09 16:38:33.239 Using username "root".
. 2015-02-09 16:38:33.279 Prompt (7, SSH password, , &Password: )
. 2015-02-09 16:38:34.918 Sent password
. 2015-02-09 16:38:34.960 Access granted

But code logs:
! 2015-02-03 11:50:28.775 Using username "root".
. 2015-02-03 11:50:28.776 Prompt (7, SSH password, , &Password: )
. 2015-02-03 11:50:28.776 Disconnected: Unable to authenticate

Quote:
And I hope you really know, what you are doing, when using .GiveUpSecurityAndAcceptAnySshHostKey.

Yes, this is ok.

Also I can connect and send file by pscp.exe using:
pscp.exe -scp -pw "" C:\Users\user1\Desktop\333.prj root@10.0.6.10:/mnt/ufs/root

So, I realy mean that I have access and there is no password or maybe empty password, but with some reason that does not work on winScp dll Sad

ps. sry for my english
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
This issue has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=1275

I have sent you an email with a development version of WinSCP to address you have used to register on this forum.

Just set Password = ""
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
prikryl wrote:
Just set Password = ""

For benefit of others, as discussed over email with Victoria already, this won't help. Improvements are needed to WinSCP to allow authentication with an empty password.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License