连接到 0.0.0.0 上的测试 SFTP 服务器
Connection to test SFTP server on 0.0.0.0
我正在尝试通过 Python 连接并上传/下载文本文件,但出现此错误:
Traceback (most recent call last):
File "C:\Users\Abdul\OneDrive\Desktop\SFTP neu\main3.py", line 8, in <module>
c.connect(hostname = "0.0.0.0",port = 22, username = "tester", pkey = k)
File "D:\Python\lib\site-packages\paramiko\client.py", line 349, in connect
retry_on_signal(lambda: sock.connect(addr))
File "D:\Python\lib\site-packages\paramiko\util.py", line 283, in retry_on_signal
return function()
File "D:\Python\lib\site-packages\paramiko\client.py", line 349, in <lambda>
retry_on_signal(lambda: sock.connect(addr))
OSError: [WinError 10049] Die angeforderte Adresse ist in diesem Kontext ungültig
我正在使用 Rebex TinySFTP Server。
起初我以为我的主人错了,但事实并非如此。
在这个例子中我使用了 0.0.0.0.
这是我的代码:
#!/usr/bin/python3
import paramiko
k = paramiko.RSAKey.from_private_key_file("C:\Users\Abdul\OneDrive\Desktop\RebexServer\private-rsa-key.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("connecting")
c.connect(hostname = "0.0.0.0",port = 22, username = "tester", pkey = k)
print("connected")
commands = ["C:\Users\Abdul\OneDrive\Desktop\RebexServer\data\testfile.txt", "C:\Users\Abdul\OneDrive\Desktop\SFTP neu\data\testfile1.txt"]
for command in commands:
print("Executing {0}".format( command ))
stdin , stdout, stderr = c.exec_command(command)
print(stdout.read())
print("Errors")
print(stderr.read())
c.close()
At first I thought my host was wrong, but that wasn't it. In this example I used 0.0.0.0
0.0.0.0
通常在 启动服务器 时使用,表示服务器应绑定到所有可用的 IP 地址。但它不是您应该在客户端中使用的内容。
使用您的服务器绑定的实际 IP 地址之一。如果两者在同一台机器上,请尝试 127.0.0.1
或您在本地使用的任何 IP 地址。以 192.168.
开头的地址在家庭和小型办公网络中很常见。
我正在尝试通过 Python 连接并上传/下载文本文件,但出现此错误:
Traceback (most recent call last):
File "C:\Users\Abdul\OneDrive\Desktop\SFTP neu\main3.py", line 8, in <module>
c.connect(hostname = "0.0.0.0",port = 22, username = "tester", pkey = k)
File "D:\Python\lib\site-packages\paramiko\client.py", line 349, in connect
retry_on_signal(lambda: sock.connect(addr))
File "D:\Python\lib\site-packages\paramiko\util.py", line 283, in retry_on_signal
return function()
File "D:\Python\lib\site-packages\paramiko\client.py", line 349, in <lambda>
retry_on_signal(lambda: sock.connect(addr))
OSError: [WinError 10049] Die angeforderte Adresse ist in diesem Kontext ungültig
我正在使用 Rebex TinySFTP Server。
起初我以为我的主人错了,但事实并非如此。 在这个例子中我使用了 0.0.0.0.
这是我的代码:
#!/usr/bin/python3
import paramiko
k = paramiko.RSAKey.from_private_key_file("C:\Users\Abdul\OneDrive\Desktop\RebexServer\private-rsa-key.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("connecting")
c.connect(hostname = "0.0.0.0",port = 22, username = "tester", pkey = k)
print("connected")
commands = ["C:\Users\Abdul\OneDrive\Desktop\RebexServer\data\testfile.txt", "C:\Users\Abdul\OneDrive\Desktop\SFTP neu\data\testfile1.txt"]
for command in commands:
print("Executing {0}".format( command ))
stdin , stdout, stderr = c.exec_command(command)
print(stdout.read())
print("Errors")
print(stderr.read())
c.close()
At first I thought my host was wrong, but that wasn't it. In this example I used 0.0.0.0
0.0.0.0
通常在 启动服务器 时使用,表示服务器应绑定到所有可用的 IP 地址。但它不是您应该在客户端中使用的内容。
使用您的服务器绑定的实际 IP 地址之一。如果两者在同一台机器上,请尝试 127.0.0.1
或您在本地使用的任何 IP 地址。以 192.168.
开头的地址在家庭和小型办公网络中很常见。