Im trying to establish a sftp connection to remote ubuntu machine.I was able to establish ssh connection.but it throws me an exception at open_sftp()
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=hostname,port=port,username=username,password=password)
sftp = ssh.open_sftp()
paramiko.SSHException: Channel closed
can anyone help me.thanks in advance.
The last time I used SFTP with Paramiko, I also had some issues. I searched a bit on the web and i found this tool : https://github.com/jbardin/scp.py
To use it :
from scp import SCPClient
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=hostname,port=port,username=username,password=password)
scpclient = SCPClient(ssh.get_transport(), socket_timeout=15.0)
scpclient.put("my_local_path", "my_remote_path")
Try this:
vim /etc/ssh/sshd_config
uncomment this line:
# Subsystem sftp /usr/libexec/openssh/sftp-server
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With