I used paramiko with python, I can file transfer but when I used exec_command function code give me channel closed error.
My Code:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=hostname,port=port,username=username,password=password, timeout=10)
transport=ssh.get_transport()
channel = transport.open_session()
channel.exec_command('ls')
out = channel.recv(-1)
print(out.decode())
Error:
paramiko.ssh_exception.SSHException: Channel closed.
I used exec_command function code give me channel closed error.