The huge pit encountered by python + paramiko for sftp remote transmission in the window10 environment

1. Error: paramiko.ssh_exception.SSHException: [WinError 10061] Could not connect because the target computer actively refused.

code show as below:

transport = paramiko.Transport(sock=(ip,22))
transport.connect(username='name', password='pwd')
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.put('./output.mp4', f'D://videos_get/output.mp4')
os.remove('./output.mp4')

I searched a lot on the Internet, ports, registry, many, many are useless, and found that the ssh service needs to be enabled.

Reason explanation :

To accept files (receive requests), the machine needs an ssh server, which is this

There is an ssh client that matches him, which is used to send files (send requests)

Processing method:

Regardless of whether the machine referred to by the requested ip address is accepting or sending the request, the client server should download it.

1. Openssh download method of windows10:

win+S and enter Settings = "Applications and Features = "Optional Features = "openSSH server, openSSH client

If not, click again

 download in

2. After downloading, win+S, enter service, find openSSH SSH Server, and set it to automatic.

3. win + S, enter cmd, right-click the command prompt and select run as administrator , enter ssh and press Enter, and a

The description is normal, and then enter  net stop sshd  to stop the service, and then enter  net start sshd  to start the service.

Guess you like

Origin blog.csdn.net/qq_40788398/article/details/124382880