Step 1: Modify jenkins sshd server
This will additionally run a bash shell
Turn on jenkins sshd server and set port.
// Activate sshd server // "Manage Jenkins" // -> // "Configure Global Security" // then copy/paste this into script console import jenkins.model.*; import org.apache.sshd.server.shell.*; def inst = Jenkins.getInstance() def sshDesc = inst.getDescriptor( "org.jenkinsci.main.modules.sshd.SSHD") sshDesc.sshd.setShellFactory( InteractiveProcessShellFactory.INSTANCE) println 'Done with step 1!'
Step 2: get sh shell
ssh -p <jenkins-sshd-port> <jenkins-fqdn>
Step 3: get python shell
python -i
Step 4: spawn pty bash shell
>>> import pty >>> pty.spawn("/bin/bash")
NOTE: bash shell has a weird double echo effect