I can run regular commands like rm /home/user/Desktop/file but when i cannot run root commands.
My intent is to configure a squid service running commands like: apt-get install squid service squid start service
but those commands require superuser authentication.
Does anyone knows how to fix it? Thanks
public void executarComandoSsh(Session session, String comando) {
try {
ChannelExec channel = (ChannelExec) session.openChannel("exec");
((ChannelExec) channel).setPty(true);
((ChannelExec) channel).setPtyType("vt100");
((ChannelExec) channel).setXForwarding(true);
System.out.println("Comando " + comando);
channel.setCommand(comando);
channel.setInputStream(null);
channel.setErrStream(System.err);
BufferedReader in = new BufferedReader(new InputStreamReader(channel.getInputStream()));
channel.connect();
String line = "";
while (true) {
while ((line = in.readLine()) != null) {
System.out.println("-- " + line);
}
break;
}
channel.disconnect();
session.disconnect();
} catch (JSchException | IOException ex) {
Logger.getLogger(ServidorNegocioImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
Solved..
i edited the /etc/sshd/sshd_config and set enable root login: yes...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.