Executing su user (without password) on paramiko ssh connection Executing su user (without password) on paramiko ssh connection shell shell

Executing su user (without password) on paramiko ssh connection


Each exec_command() call happens in a new shell, so there is no state carried over from previous commands. If commands rely on a previous command to execute, you have to send them in a single statement, or as a script. If you want an interactive shell, there is the invoke_shell command, but then you need to parse the shell output to simulate interactive use (the pexpect library can be used here).

You can use the sudo command, or su -c to execute the command.. However, I would suggest configuring a secure login for the needed user, and connecting as that user directly.