I am trying to change the UNIX password using passwd command. passwd command has got some prompts depending on the Operating system. Using Jsch i tried to establish connection and execute the command.
JSch jsch = new JSch();
Session session = jsch.getSession(username, hostname, 22);
UserInfo ui = new MyUserInfo();
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand("passwd " + username);
InputStream in = channel.getInputStream();
After giving the value to the first prompt, Enter existing login password: , it is prompting the next prompt. It appears ssh connection is not handling the 2-way communication. Please help me out to resolve the issue.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.