Monday, May 27, 2019

Connect to SFTP with both password and key on webMethods

Problem

I couldn't recall since when webMethods starts to support SFTP client. Maybe version 9? It's a great feature, so we could connect to SFTP server easily, but it's not perfect. To connect with a SFTP server, we need to configure a User Alias first, but we could only select either Password or Public Key as the Authentication Type. What if your server is asking for both? You will get an Auth fail exception when you try to login.

Reason

When servicpub.client.sftp:login is invoked, it will call method public Session SFTPClientManager.login(String userAlias) to establish the connection with SFTP server based on the User Alias information. The connection would be established differently based on your choice on Authentication Type field, but none of them would handle both Password and Public Key correctly.

Solution

What you need is a customized login service which could retrieve Password and Public Key from User Alias and handle them correctly. With that you could even reuse the generated Session with other services under pub.client.sftp folder as a native one.
To use this customized login service, you will need to:

  1. Create a SFTP User Alias on IS Administrator UI as usual.
  2. Make sure this User Alias is configured twice for different Authentication Type. For example, firstly you configure it to use Password, and after saving, modify it to use Public key.
  3. Invoke servicHxEnhancedSftpClient:login to connect to SFTP server by the given User Alias you created in step 1. This service has the exactly same service signature with pub.client.sftp:login.
You could download this package form GitHub, https://github.com/dingago/HxEnhancedSftpClient. The code is verified on webMethods 9.9 and CrushFTP 9.

Comments

  • If you're having issue Invalid private key, you probably need to regenerate the private key in PuTTY format, which is generate by PuTTYgen.
  • If you're having issue The cipher 'xxx' is required but it is not available, you probably need to replace current JCE jars.

No comments:

Post a Comment

Extendable System Monitor on webMethods

System Connectivity Monitoring There could be hundreds of systems integrated in a big company, and it's a challenge for administrator...