Run a daemon within a namespace on a remote host. (Robot Framework)

Viewed 130

I'm writing a keyword in Robot Framework, that should connect to some remote host and start a daemon/server (e. g. SSH daemon) within a network namespace, presented on this remote host. I am using the SSHLibrary to build the connection to the remote host, and execute a command that should start the given daemon. The example of the keyword is below.

Start daemon
     ${cmd}=     Set Variable    ip netns exec NAMESPACE CMD_TO_START_DAEMON
     Open connection  REMOTE_HOST
     Login  USERNAME  PASSWORD
     ${output}=  Execute Command     ${cmd}  return_rc=True  sudo=True  sudo_password=SUDO_PSWD
     Should Be Equal As Integers  ${output}[1]  0 

The problem is, that with this implementation nothing will be started. The keyword also reports no errors. The output looks like this:

${output} = [sudo] password for USERNAME:

The sudo password is correct. If I execute the same command in the terminal on the remote host directly, it works perfectly. If I try to start the daemon, not in the namespace, but on the remote host itself using the "Execute Command"-keyword, it works also. The keyword also does a great job, if I want just execute a command within a namespace, but then I try to start a daemon, I always run into this problem. The same problem, if I use the "Start Command"-keyword instead of "Execute Command".

The remote host is an Ubuntu Server(18.04.3)

Maybe someone has an explanation for this behavior? Or maybe any suggestion on how I can do the same in some other way?

Thank you for your time!

1 Answers
  1. If it's possible to login as root add your public key and login with keyword Login With Public Key.

  2. If you can't connect to server as root user you try interactive shell instead

Like this

Write  sudo su
Write  valid_sudo_password
Write  ${cmd}
Related