Topic "Cannot connect using poweshell"

Author Message
johanndm

Guest


Hi,

I'm trying to connect to a debian system using poweshell and keep getting authentication failure.

I have setup public/private key pairs and can login 100% with the gui interface - no problems. But when I try the same with the script (powershell) authentication fails?

Here's the script and auth.log output:

Trying to connect from a script: (this fails)
//script
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "myhostname"
$sessionOptions.UserName = "www-data"
$sessionOptions.SshPrivateKeyPath = "c:\bmprivate.ppk"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
// script end

Aug 15 13:43:27 (none) sshd[25042]: debug1: Forked child 26188.
Aug 15 13:43:27 (none) sshd[26188]: Set /proc/self/oom_adj to -17
Aug 15 13:43:27 (none) sshd[26188]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Aug 15 13:43:27 (none) sshd[26188]: debug1: inetd sockets after dupping: 3, 3
Aug 15 13:43:27 (none) sshd[26188]: Connection from xx.xx.xx.xx port 40003
Aug 15 13:43:27 (none) sshd[26188]: debug1: Client protocol version 2.0; client software version WinSCP_release_5.5.4
Aug 15 13:43:27 (none) sshd[26188]: debug1: no match: WinSCP_release_5.5.4
Aug 15 13:43:27 (none) sshd[26188]: debug1: Enabling compatibility mode for protocol 2.0
Aug 15 13:43:27 (none) sshd[26188]: debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze5
Aug 15 13:43:28 (none) sshd[26188]: debug1: PAM: initializing for "www-data"
Aug 15 13:43:28 (none) sshd[26188]: debug1: PAM: setting PAM_RHOST to "xx.xx.xx.xx"
Aug 15 13:43:28 (none) sshd[26188]: debug1: PAM: setting PAM_TTY to "ssh"
Aug 15 13:43:28 (none) sshd[26188]: Failed none for www-data from xx.xx.xx.xx port 40003 ssh2
Aug 15 13:43:28 (none) sshd[26188]: debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
Aug 15 13:43:28 (none) sshd[26188]: debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
Aug 15 13:43:28 (none) sshd[26188]: debug1: temporarily_use_uid: 33/33 (e=0/0)
Aug 15 13:43:28 (none) sshd[26188]: debug1: trying public key file /var/www/.ssh/authorized_keys
Aug 15 13:43:28 (none) sshd[26188]: debug1: fd 4 clearing O_NONBLOCK
Aug 15 13:43:28 (none) sshd[26188]: debug1: restore_uid: 0/0
Aug 15 13:43:28 (none) sshd[26188]: debug1: temporarily_use_uid: 33/33 (e=0/0)
Aug 15 13:43:28 (none) sshd[26188]: debug1: trying public key file /var/www/.ssh/authorized_keys2
Aug 15 13:43:28 (none) sshd[26188]: debug1: restore_uid: 0/0
Aug 15 13:43:28 (none) sshd[26188]: Failed publickey for www-data from xx.xx.xx.xx port 40003 ssh2
Aug 15 13:43:28 (none) sshd[26188]: debug1: do_cleanup
Aug 15 13:43:28 (none) sshd[26188]: debug1: PAM: cleanup


Connecting from the UI: (this works perfect)
Aug 15 13:45:17 (none) sshd[25042]: debug1: Forked child 26191.
Aug 15 13:45:17 (none) sshd[26191]: Set /proc/self/oom_adj to -17
Aug 15 13:45:17 (none) sshd[26191]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Aug 15 13:45:17 (none) sshd[26191]: debug1: inetd sockets after dupping: 3, 3
Aug 15 13:45:17 (none) sshd[26191]: Connection from 90.179.141.72 port 34017
Aug 15 13:45:17 (none) sshd[26191]: debug1: Client protocol version 2.0; client software version WinSCP_release_5.5.4
Aug 15 13:45:17 (none) sshd[26191]: debug1: no match: WinSCP_release_5.5.4
Aug 15 13:45:17 (none) sshd[26191]: debug1: Enabling compatibility mode for protocol 2.0
Aug 15 13:45:17 (none) sshd[26191]: debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze5
Aug 15 13:45:19 (none) sshd[26191]: debug1: PAM: initializing for "www-data"
Aug 15 13:45:19 (none) sshd[26191]: debug1: PAM: setting PAM_RHOST to "xx.xx.xx.xx"
Aug 15 13:45:19 (none) sshd[26191]: debug1: PAM: setting PAM_TTY to "ssh"
Aug 15 13:45:19 (none) sshd[26191]: Failed none for www-data from xx.xx.xx.xx port 34017 ssh2
Aug 15 13:45:19 (none) sshd[26191]: debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
Aug 15 13:45:19 (none) sshd[26191]: debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
Aug 15 13:45:19 (none) sshd[26191]: debug1: temporarily_use_uid: 33/33 (e=0/0)
Aug 15 13:45:19 (none) sshd[26191]: debug1: trying public key file /var/www/.ssh/authorized_keys
Aug 15 13:45:19 (none) sshd[26191]: debug1: fd 4 clearing O_NONBLOCK
Aug 15 13:45:19 (none) sshd[26191]: debug1: restore_uid: 0/0
Aug 15 13:45:19 (none) sshd[26191]: debug1: temporarily_use_uid: 33/33 (e=0/0)
Aug 15 13:45:19 (none) sshd[26191]: debug1: trying public key file /var/www/.ssh/authorized_keys2
Aug 15 13:45:19 (none) sshd[26191]: debug1: restore_uid: 0/0
Aug 15 13:45:19 (none) sshd[26191]: Failed publickey for www-data from xx.xx.xx.xx port 34017 ssh2
Aug 15 13:45:19 (none) sshd[26191]: debug1: PAM: password authentication accepted for www-data
Aug 15 13:45:19 (none) sshd[26191]: debug1: do_pam_account: called
Aug 15 13:45:19 (none) sshd[26191]: Accepted password for www-data from xx.xx.xx.xx port 34017 ssh2
Aug 15 13:45:19 (none) sshd[26191]: debug1: monitor_child_preauth: www-data has been authenticated by privileged process
Aug 15 13:45:19 (none) sshd[26191]: debug1: PAM: establishing credentials
Aug 15 13:45:19 (none) sshd[26191]: pam_unix(sshd:session): session opened for user www-data by (uid=0)
Aug 15 13:45:19 (none) sshd[26191]: User child is on pid 26194
Aug 15 13:45:19 (none) sshd[26194]: debug1: SELinux support disabled
Aug 15 13:45:19 (none) sshd[26194]: debug1: PAM: establishing credentials
Aug 15 13:45:19 (none) sshd[26194]: debug1: permanently_set_uid: 33/33
Aug 15 13:45:19 (none) sshd[26194]: debug1: Entering interactive session for SSH2.
Aug 15 13:45:19 (none) sshd[26194]: debug1: server_init_dispatch_20
Aug 15 13:45:19 (none) sshd[26194]: debug1: server_input_channel_open: ctype session rchan 256 win 2147483647 max 16384
Aug 15 13:45:19 (none) sshd[26194]: debug1: input_session_request
Aug 15 13:45:19 (none) sshd[26194]: debug1: channel 0: new [server-session]
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_new: session 0
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_open: channel 0
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_open: session 0: link with channel 0
Aug 15 13:45:19 (none) sshd[26194]: debug1: server_input_channel_open: confirm session
Aug 15 13:45:19 (none) sshd[26194]: debug1: server_input_channel_req: channel 0 request simple@putty.projects.tartarus.org reply 0
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_by_channel: session 0 channel 0
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_input_channel_req: session 0 req simple@putty.projects.tartarus.org
Aug 15 13:45:19 (none) sshd[26194]: debug1: server_input_channel_req: channel 0 request subsystem reply 1
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_by_channel: session 0 channel 0
Aug 15 13:45:19 (none) sshd[26194]: debug1: session_input_channel_req: session 0 req subsystem
Aug 15 13:45:19 (none) sshd[26194]: subsystem request for sftp
Aug 15 13:45:19 (none) sshd[26194]: debug1: subsystem: exec() /usr/lib/openssh/sftp-server

Error message on the windows side: Connection has been unexpectedly closed. Server sent command exit status 0.

More detail:
WinSCP Version: 5.5.4 (build 4433)
Running on Windows 2008 R2 Service Pack 1
Connecting to Debian 6 (Squeeze 5) with OpenSSH

I have tried using password authentication but get the same issue - works via the gui, but not with the script?

Any pointers will be great!!

Thanks
Johann
johanndm

Guest


Ok - got it working. Had to remove the passphrase from the private key Shocked
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