From b2c8df506599472a3b9acd2d608faffe78394b14 Mon Sep 17 00:00:00 2001 From: leebj Date: Tue, 24 Sep 2024 15:47:36 +0900 Subject: [PATCH] =?UTF-8?q?SFTP=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC?= =?UTF-8?q?=EB=A6=AC=20=EB=B2=84=EC=A0=84=20=EC=88=98=EC=A0=95,=20ssh?= =?UTF-8?q?=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/java/cokr/xit/fims/cmmn/ftp/SFTPUtil.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 830fb5e1..4323a389 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,7 @@ com.github.mwiede jsch - 0.2.20 + 0.1.72 diff --git a/src/main/java/cokr/xit/fims/cmmn/ftp/SFTPUtil.java b/src/main/java/cokr/xit/fims/cmmn/ftp/SFTPUtil.java index a808683a..bb66898f 100644 --- a/src/main/java/cokr/xit/fims/cmmn/ftp/SFTPUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/ftp/SFTPUtil.java @@ -29,9 +29,12 @@ public class SFTPUtil { //세션관련 설정정보 설정 java.util.Properties config = new java.util.Properties(); + String kex = session.getConfig("kex"); + String oldKex = "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1"; - //호스트 정보 검사하지 않는다. - config.put("StrictHostKeyChecking", "no"); + + config.put("StrictHostKeyChecking", "no"); //호스트 정보 검사하지 않는다. + config.put("kex", oldKex+","+kex); session.setConfig(config); session.setTimeout(10000); @@ -41,6 +44,7 @@ public class SFTPUtil { } catch (NumberFormatException e) { throw new RuntimeException("[F] FTP 접속 오류"); } catch (JSchException e) { + e.printStackTrace(); throw new RuntimeException("[F] FTP 접속 오류"); } channelSftp = (ChannelSftp) channel; @@ -61,7 +65,11 @@ public class SFTPUtil { try { is = channelSftp.get(path); } catch (SftpException e) { - throw new RuntimeException("[F] FTP 파일 읽기 오류"); + if(e.getMessage().equals("No such file")) { + return null; + } else { + throw new RuntimeException("[F] FTP 파일 읽기 오류"); + } } if(is == null) {