Python2.7:ssh.exec_command适用于Ubuntu而不适用于FreeBSD

时间:2016-06-29 09:30:14

标签: python linux python-2.7 ssh strace

我正在使用SSH Channel向远程主机创建paramiko。但是,当我尝试使用ssh_object.exec_command执行任何命令时,该命令似乎不会在 FreeBSD框上执行,但它适用于Ubuntu框。我是否需要在远程计算机中检查任何权限问题或先决条件?

此函数创建我的ssh处理程序:

def ssh_connect(ip,user,pwd):
    '''
    This function will make an ssh connection to the ip using the credentials passed and return the handler
    Args:
        ip: IP Address of the box into which ssh has to be done
        user: User name of the box to which ssh has to be done
        pass: password of the box to which ssh has to be done
    Returns:
        An ssh handler
    '''
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip, username=user, password=pwd)  
    return ssh

这就是我使用处理程序的地方:

ssh_obj = ssh_connect(ip, username, password)
folder = "/var/xyz/images/" + build_number
command = "mkdir " + folder
ssh_stdin, ssh_stdout, ssh_stderr = ssh_obj.exec_command(command)

当我转到远程计算机时,文件夹尚未创建。同样,我也尝试读取ls命令的输出。当我ssh_stdout.read()时,没有回复。

我运行ssh_stderr.read()时没有响应。

进程ID的strace卡在此处:

root@ubuntu:~# strace -p 2368
Process 2368 attached
futex(0xef1e20, FUTEX_WAIT_PRIVATE, 0, NULL

我哪里错了?

0 个答案:

没有答案