Uprava po zmene hesiel na unipickach

This commit is contained in:
rasta5man 2025-05-05 12:57:45 +02:00
parent 73de386857
commit 7f5697b2a1
6 changed files with 51 additions and 20 deletions

View file

@ -21,14 +21,15 @@ public class CommandExecutor {
allServers = new BuildServerArray().getAllServers();
timeBetweenCommands = 1; // in seconds (if rebooting, put cca 20 seconds between reboots)
// commandsToExecute = "tail -n 3 flowserver/monitor.txt";
// commandsToExecute = "sudo journalctl --vacuum-size=1M";
// commandsToExecute = "sudo service nodejs restart";
commandsToExecute = "sudo service nodejs start";
// commandsToExecute = "rm -rf /home/unipi/flowserver/flow";
// commandsToExecute = "mkdir -p /home/unipi/flowserver/flow/helper";
// commandsToExecute = "sudo reboot";
commandsToExecute = "python /root/flowserver/addSwitch.py";
commandsToExecute = "python3 /home/unipi/flowserver/addSwitch.py";
commandsToExecute = "sudo service nodejs stop";
commandsToExecute = "tail -n 3 flowserver/monitor.txt";
// commandsToExecute = "sudo reboot";
// commandsToExecute = "ls -l /home/unipi/flowserver/databases";
// commandsToExecute = "ls -l /root/flowserver/databases";
@ -45,11 +46,15 @@ public class CommandExecutor {
public void open(String username, String hostname, String password) throws JSchException {
JSch jSch = new JSch();
jSch.setKnownHosts("/home/rasta5man/.ssh/known_hosts");
jSch.addIdentity( "/home/rasta5man/.ssh/oms_key" );
session = jSch.getSession(username, hostname, 22);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no"); // not recommended
session.setConfig(config);
// Properties config = new Properties();
//config.put("StrictHostKeyChecking", "no"); // not recommended
//session.setConfig("StrictHostKeyChecking", "no"); // not recommended
//session.setConfig("PreferredAuthentications", "password");
//session.setConfig(config);
session.setPassword(password);
System.out.println("Connecting SSH to " + hostname + " - Please wait for few seconds... ");