jsch

How to automate challenge-response authentication using Java

余生颓废 提交于 2021-02-04 19:35:26
问题 I have Linux phone with enabled SSH. I need to connect to it via challenge-response authentication. So how looks this process manually, for example, using PuTTY: Connect to phone using IP and port. Console shows "login as:" -> Enter user name. Console shows: login as: craft Challenge: 547-04302 Product ID: 7000315107 Response: I need to copy Challenge, get Response from other server using Challenge and enter the Response in console. How I can do this using Java and some libraries for SSH (I

jsch连接sftp后连接未释放掉问题排查

≯℡__Kan透↙ 提交于 2021-01-13 03:08:21
项目中通过jsch中的sftp实现上传下载文件。在压测过程中,由于调用到sftp,下载文件不存在时,系统不断抛出异常,内存飙升,逐渐把swap区也占满,通过top监控未发现占用内存的进程,通过查找sshd进程,发现服务器多了很多sftp的进程没有被关闭。 刚开始以为是sftp公共方法设计的有问题,每次创建连接都未释放,下面是部分代码片段 @Repository("SftpClient" ) public class SftpClient { private Logger logger = LoggerFactory.getLogger(SftpClient. class ); private ThreadLocal<Session> sessionLocal = new ThreadLocal<Session> (); private ThreadLocal<ChannelSftp> channelLocal = new ThreadLocal<ChannelSftp> (); // 初始化连接 public SftpClient init() { try { String host = SFTP_HOST; int port = Integer.valueOf(SFTP_PORT); String userName = SFTP_USER_NAME; String

My JSch session doesn't execute command

末鹿安然 提交于 2021-01-01 06:37:37
问题 I'm trying to write a Java code that can ssh into a Unix server and reset a user's password. So I tried to implement some of the code found in SO. Eg. Sending commands to remote server through ssh by Java with JSch Take commands(password) from string and set as InputStream to Unix servers in Java (JSCH) Using JSch ChannelExec , I followed this link to get the proper command for resetting user's password. When I tried running this code, seems like it doesn't reset the user's password. So I

Command using ChannelExec not executed - Jsch

笑着哭i 提交于 2020-11-29 03:56:25
问题 I am using Jsch to create a file in the server and execute some commands. For the file creation, it's working fine, however, for the command execution, doesn't. It keeps the status -1 (still working on it) and keep there forever. This happen for shell execution or when I try to became root. Follow the method used below: public void upload(String localPath) throws IOException { Session session = connectToServer(); System.out.println("In upload"); ChannelSftp channelSftp =

Command using ChannelExec not executed - Jsch

久未见 提交于 2020-11-29 03:55:04
问题 I am using Jsch to create a file in the server and execute some commands. For the file creation, it's working fine, however, for the command execution, doesn't. It keeps the status -1 (still working on it) and keep there forever. This happen for shell execution or when I try to became root. Follow the method used below: public void upload(String localPath) throws IOException { Session session = connectToServer(); System.out.println("In upload"); ChannelSftp channelSftp =

Command using ChannelExec not executed - Jsch

谁都会走 提交于 2020-11-29 03:55:04
问题 I am using Jsch to create a file in the server and execute some commands. For the file creation, it's working fine, however, for the command execution, doesn't. It keeps the status -1 (still working on it) and keep there forever. This happen for shell execution or when I try to became root. Follow the method used below: public void upload(String localPath) throws IOException { Session session = connectToServer(); System.out.println("In upload"); ChannelSftp channelSftp =