0

l would like to use the "With Ftp session" component to configure my connection to the SFTP server, However instead of using password i am using a key file. But i always have this error when i try to connect

Exception screen

Here is my config:

Activity Config

Ilya Kochetov
  • 17,988
  • 6
  • 44
  • 60
Syllaba Abou Ndiaye
  • 213
  • 1
  • 7
  • 21
  • Your Activity properties screen does not look like you're using the latest version of the FTP Activities pack. Could you please add details of which version of UiPath platform and which version of the Activity you are using to your question? – Ilya Kochetov Aug 28 '19 at 14:19
  • I am using UiPath 2019.7, and the ftp version is 1.0.7053.27728 – Syllaba Abou Ndiaye Aug 29 '19 at 11:22
  • I could confirm that it's a bug with the latest version of open source Community Activities With FTP Session activity – Ilya Kochetov Aug 31 '19 at 21:36
  • JFYI I identified the fix (missing code in SftpSession.cs) and will try to upload an updated version of the activity to Github soon – Ilya Kochetov Aug 31 '19 at 22:37

1 Answers1

0

The With FTP Session activity ignored the private key argument and always tried to connect with a password. The error you were getting were due to the SSH library receiving an unitialized password variable.

This is the update code for the Activities/FTP/UiPath.FTP/SftpSession.cs which adds PrivateKey authentication mechanism. I will contribute this fix to the Github meanwhile.

Note that you will have to clone and build https://github.com/UiPath/Community.Activities) for this to work.

 public SftpSession(FtpConfiguration ftpConfiguration)
    {
        if (ftpConfiguration == null)
        {
            throw new ArgumentNullException(nameof(ftpConfiguration));
        }

        ConnectionInfo connectionInfo = null;

        var auths = new List<AuthenticationMethod>();
        if (!String.IsNullOrEmpty(ftpConfiguration.Password))
        {
            auths.Add(new PasswordAuthenticationMethod(ftpConfiguration.Username, ftpConfiguration.Password));
        }

        if (!String.IsNullOrEmpty(ftpConfiguration.ClientCertificatePath)) {
            PrivateKeyFile keyFile = new PrivateKeyFile(ftpConfiguration.ClientCertificatePath, ftpConfiguration.ClientCertificatePassword);
            var keyFiles = new[] { keyFile };
            auths.Add(new PrivateKeyAuthenticationMethod(ftpConfiguration.Username, keyFiles));
        }

        if (auths.Count == 0)
        {
            throw new ArgumentNullException("Need to provide either private key or password");
        }

        if (ftpConfiguration.Port == null)
        {
            connectionInfo = new ConnectionInfo(ftpConfiguration.Host, ftpConfiguration.Username, auths.ToArray());
        }
        else
        {
            connectionInfo = new ConnectionInfo(ftpConfiguration.Host, ftpConfiguration.Port.Value, ftpConfiguration.Username, auths.ToArray());
        }

        _sftpClient = new SftpClient(connectionInfo);

    }
Ilya Kochetov
  • 17,988
  • 6
  • 44
  • 60