python how to run code in ssh 1

python how to run code in ssh

stdout = client.exec_command('python -c "exec(\\"' + open('hello.py','r').read().encode('base64').strip('\n') + '\\".decode(\\"base64\\"))"' )[1]

Here is what the above code is Doing:
1. It’s opening the hello.py file and reading it’s contents.
2. It’s encoding the contents of the file in base64.
3. It’s stripping the newline character from the encoded string.
4. It’s executing the command python -c “exec(‘‘.decode(‘base64’))”
5. It’s printing the output of the command.

Similar Posts