我正在尝试远程获取FTP用户的目录结构。我是使用[spur] [1]模块从python脚本执行此操作。我使用cron作业调用此脚本。但我得到以下
Traceback (most recent call last):
File "/mnt/voylla-staging/releases/20140717193920/voylla_scripts/snapdeal/GetOrders/getOrders.py", line 54, in <module>
feeds = getFeeds()
File "/mnt/voylla-staging/releases/20140717193920/voylla_scripts/snapdeal/GetOrders/getOrders.py", line 26, in getFeeds
result = shell.run(["ls", FEED_LOCATION])
File "/usr/local/lib/python2.7/dist-packages/spur/ssh.py", line 73, in run
return self.spawn(*args, **kwargs).wait_for_result()
File "/usr/local/lib/python2.7/dist-packages/spur/ssh.py", line 83, in spawn
channel = self._get_ssh_transport().open_session()
File "/usr/local/lib/python2.7/dist-packages/spur/ssh.py", line 190, in _get_ssh_transport
raise self._connection_error(error)
spur.ssh.ConnectionError: Error creating SSH connection
Original error: Authentication failed.
如果我在不使用cron的情况下手动运行scipt,它的运行完美! 请有人帮忙。
由于
相关守则:
FTP_SERVER = "abc.example.com"
FTP_USER = "root"
FEED_LOCATION = "/home/xyz/abc"
PROCESSED_FEED_LOCATION = "/home/xyz/def"
PREFIX = "alpha"
def getFeeds(): ####returns the list of feeds in FEED_LOCATION
shell = spur.SshShell(hostname=FTP_SERVER, username=FTP_USER)
with shell:
result = shell.run(["ls", FEED_LOCATION])
feeds = result.output.decode().split("\n")
return feeds
feeds = getFeeds()
答案 0 :(得分:1)
您必须使用private_key_file
选项指定私钥文件的路径。以下是documentation的示例。
# Use a private key
spur.SshShell(
hostname="localhost",
username="bob",
private_key_file="path/to/private.key"
)