paramiko
を使用してリモートホストにSSH Channel
を作成しています。しかし、ssh_object.exec_command
を使用してコマンドを実行しようとすると、コマンドが実行されないようです。Python2.7:ssh.exec_commandがコマンドを実行していません
この関数は、私の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にログインしているかどうか確認できますか? –
@AlekhyaVemavarapu、どうすれば確認できますか? –
コマンド= "mkdir -p" +フォルダ – skynyrd