diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b0d9402..f3441d4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -32,11 +32,12 @@ jobs:
- name: Install and start SFTP
run: |
+ sudo apt install sshpass
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo sh -c 'echo "PubkeyAcceptedAlgorithms +ssh-rsa" >> /etc/ssh/sshd_config'
- sudo systemctl restart ssh
+ sudo systemctl try-reload-or-restart ssh
sudo cat /etc/ssh/sshd_config
- name: Create a test user account
@@ -46,17 +47,9 @@ jobs:
echo "adding user to group ${sshGroup}"
sudo useradd -s /bin/bash -d /home/usr -m -g ${sshGroup} -p $(echo pwd | openssl passwd -1 -stdin) usr
- sudo -u usr ssh-keygen -t rsa -N "123456" -f /home/usr/.ssh/sftptest
- sudo -u usr sh -c 'cat /home/usr/.ssh/sftptest.pub >> /home/usr/.ssh/authorized_keys'
- sudo chmod -R 600 /home/usr/.ssh/
- sudo chmod 700 /home/usr/.ssh/authorized_keys
- sudo cat /home/usr/.ssh/sftptest.pub
- sudo cat /home/usr/.ssh/authorized_keys
+ ssh-keygen -t rsa -N "123456" -f ~/.ssh/sftptest
+ sshpass -p pwd ssh-copy-id -i ~/.ssh/sftptest.pub usr@localhost
- sudo cp /home/usr/.ssh/sftptest ${GITHUB_WORKSPACE}/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/sftptest
- sudo ssh-keygen -p -P "123456" -N "123456" -m pem -f ${GITHUB_WORKSPACE}/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/sftptest
- sudo chown "$(whoami)" ${GITHUB_WORKSPACE}/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/sftptest
-
- name: Setup Maven
uses: stCarolas/setup-maven@v5
with:
@@ -68,6 +61,7 @@ jobs:
- name: Print out log
run: |
sudo journalctl -u ssh
+ echo "======================================================="
sudo cat /var/log/auth.log
# - name: Publish Unit Test Results
diff --git a/sftp-connector/config/variables.yaml b/sftp-connector/config/variables.yaml
index 272aa86..afe98cb 100644
--- a/sftp-connector/config/variables.yaml
+++ b/sftp-connector/config/variables.yaml
@@ -11,15 +11,14 @@ Variables:
username: 'usr'
# Auth type to the SFPT server: password OR ssh
- auth: 'password'
+ auth: 'ssh'
# The password to the SFTP server
# [password]
- password: pwd
+ password: ''
# The ssh key string to SFTP server
# [secret private key]
- secret_sshkey: ''
-
+ secret.sshkey: ''
# The ssh key passphrase
- secret_sshpassphrase: ''
+ secret.sshpassphrase: ''
diff --git a/sftp-connector/pom.xml b/sftp-connector/pom.xml
index 119c50d..6d43de1 100644
--- a/sftp-connector/pom.xml
+++ b/sftp-connector/pom.xml
@@ -11,9 +11,9 @@
- com.jcraft
+ com.github.mwiede
jsch
- 0.1.55
+ 0.2.19
diff --git a/sftp-connector/src/com/axonivy/connector/sftp/service/SftpClientService.java b/sftp-connector/src/com/axonivy/connector/sftp/service/SftpClientService.java
index a2d2616..633248c 100644
--- a/sftp-connector/src/com/axonivy/connector/sftp/service/SftpClientService.java
+++ b/sftp-connector/src/com/axonivy/connector/sftp/service/SftpClientService.java
@@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@@ -56,6 +57,7 @@ public class SftpClientService implements AutoCloseable {
*/
public SftpClientService(String host, int port, String username, String authType, String password, String keyString, String passphrase) throws IOException {
System.out.println(keyString);
+ System.out.println(passphrase);
try {
JSch jsch = new JSch();
@@ -63,6 +65,11 @@ public SftpClientService(String host, int port, String username, String authType
if (StringUtils.isEmpty(authType) || PASSWORD.equalsIgnoreCase(authType)) {
session.setPassword(password);
} else {
+ session.setConfig("PreferredAuthentications", "publickey");
+// Properties config = new Properties();
+// config.put("PubkeyAcceptedKeyTypes", "ssh-rsa");
+// config.put("HostKeyAlgorithms", "ssh-rsa");
+// session.setConfig(config);
jsch.addIdentity(null, keyString.getBytes(), null, passphrase.getBytes());
}