When using ssh to execute remote scripts containing "sudo" you get the following error if /etc/sudoers contains "Defaults requiretty". sudo: sorry, you must have a tty to run sudo The solution is to edit your sudoers file or add support for pseudo tty allocation (this is the same as the ssh -t option in unix). Adding support for pseudo tty connections is a minor change: In SSHExec.java private boolean tty = false; public void setTty(boolean tty) { this.tty = tty; } private void executeCommand(Session session, String cmd, StringBuffer sb) ... final ChannelExec channel; session.setTimeout((int) maxwait); /* execute the command */ channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(cmd); channel.setOutputStream(tee); channel.setExtOutputStream(tee); if (istream != null) { channel.setInputStream(istream); } + channel.setPty(tty); channel.connect();
added with svn revision 1239121