Skip to content

Creating session trough SFTP with SSH key is no working - cannot define username #88

@theLoFix

Description

@theLoFix

Issue Description

I'm trying to open session with generated SSH key, but when open session module is trying to connect as anonymous user. How can I defined name of the user I want to be logged to? addinf Credential option will pop out password prompt...

Example

$sessionOptions = New-WinSCPSessionOption -HostName $Hostname -Protocol sftp -SshHostKeyFingerprint $SshHostKeyFingerprint -SshPrivateKeyPath $SshPrivateKeyPath -SecurePrivateKeyPassphrase $SecurePrivateKeyPassphrase

Expected Output

Connection should be established via SSH key on defined user.

Actual Output

New-WinSCPSession : Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0.
Authentication log (see session log for details):
Using username "anonymous".
Server refused our key.
Authentication failed."
At line:1 char:25
+ ...           $session = New-WinSCPSession -SessionOption $sessionOptions
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-WinSCPSession], MethodInvocationException
    + FullyQualifiedErrorId : SessionRemoteException,New-WinSCPSession

WinSCP-PowerShell Version

ModuleType Version    Name                                ExportedCommands                                                                                                 
---------- -------    ----                                ----------------                                                                                                 
Script     0.0.0.0    WinSCP                              {ConvertTo-WinSCPEscapedString, Copy-WinSCPItem, Get-WinSCPChildItem, Get-WinSCPHostKeyFingerprint...}     

Environment

FTP:
SUSE Linux Enterprise Server 12 SP3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions