So, I have written a small python code which hangs on exec_command step when using support user and the same works fine while using root user

I have no problems running the script from the terminal when logged in as the support user. This is what I am unable to understand why does paramiko.exec_command hangs.

I have tried running the script from windows 10 running python Python 3.6.6 |Anaconda custom (64-bit)| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32 as well as ubuntu 19.04 running Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0] :: Anaconda, Inc. on linux

The machine I am trying to ssh is running CentOS release 6.9 (Final) Here is ls -ltr on this machine

-rwxr-xr-x. 1 support support 10430264 May 10 12:13 port_check

I have tried adding and removing sudo from the commands to be executed over SSH and also commenting ssh.invoke_shell()

import sys
import paramiko

def pew_print(some_input):
        some_input = some_input.decode("utf-8")
    except Exception as errors:
        print("Errors : {0}".format(errors))
    some_input = str(some_input)

def ssh_command_output(ssh, command_string):

    # ssh.invoke_shell()
    stdin, stdout, stderr = ssh.exec_command(command_string, timeout=90)

def something(ip_address):

    ssh = paramiko.SSHClient()
    ssh.connect(hostname=ip_address, port=22, username="support", password="pass")
    # ssh_command_output(ssh, "sudo chmod 755 /home/support/port_check")
    # ssh_command_output(ssh, "sudo /home/support/port_check")
    ssh_command_output(ssh, "ls -ltr")

I expect the result to be the same when using support user when it is using root user


sudo on support user doesn't require password and I have tried just executing ls -ltr from support user and this hangs as well.

I can normally ssh [email protected] and then execute all the above commands

1 Answers

Sam Si On Best Solutions

So after digging a bit about the problem. I found out that remote execution is not allowed and hence closing this question.