不能使用面料 - 是否需要任何服务器配置?

Jua*_*hin 6 python ubuntu fabric

我正在使用fabric机架空间服务器远程部署我的应用程序.我在家用计算机上使用相同的操作系统(Ubuntu Server 10.04)在虚拟机上尝试过我的脚本,它们似乎都可以工作.

奇怪的是,所有put结构命令都在真实服务器上失败.所有其它命令(run,cd,sudo等),似乎工作正常.

这只在针对此特定服务器时发生,这是我执行的命令:

fab test --host remote-server
Run Code Online (Sandbox Code Playgroud)

remote-server是我的别名.ssh/config.我的fabfile:

@task
def test():
    sudo("echo testing")
    put("/tmp/file.txt", "/tmp/")
Run Code Online (Sandbox Code Playgroud)

tmp/test_file.txt 只是我用于测试的文本文件

这是输出

[remote-server] Executing task 'test'
[remote-server] sudo: echo testing
[remote-server] out: testing

Traceback (most recent call last):
  File "/home/user/env/lib/python2.6/site-packages/fabric/main.py", line 712, in main
    *args, **kwargs
  File "/home/user/env/lib/python2.6/site-packages/fabric/tasks.py", line 298, in execute
    multiprocessing
  File "/home/user/env/lib/python2.6/site-packages/fabric/tasks.py", line 197, in _execute
    return task.run(*args, **kwargs)
  File "/home/user/env/lib/python2.6/site-packages/fabric/tasks.py", line 112, in run
    return self.wrapped(*args, **kwargs)
  File "/home/user/project/fabfile/__init__.py", line 33, in test
    put("/tmp/file.txt", "/tmp/")
  File "/home/user/env/lib/python2.6/site-packages/fabric/network.py", line 457, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/home/user/env/lib/python2.6/site-packages/fabric/operations.py", line 338, in put
    ftp = SFTP(env.host_string)
  File "/home/user/env/lib/python2.6/site-packages/fabric/sftp.py", line 20, in __init__
    self.ftp = connections[host_string].open_sftp()
  File "/home/user/env/lib/python2.6/site-packages/ssh/client.py", line 399, in open_sftp
    return self._transport.open_sftp_client()
  File "/home/user/env/lib/python2.6/site-packages/ssh/transport.py", line 844, in open_sftp_client
    return SFTPClient.from_transport(self)
  File "/home/user/env/lib/python2.6/site-packages/ssh/sftp_client.py", line 105, in from_transport
    chan.invoke_subsystem('sftp')
  File "/home/user/env/lib/python2.6/site-packages/ssh/channel.py", line 240, in invoke_subsystem
    self._wait_for_event()
  File "/home/user/env/lib/python2.6/site-packages/ssh/channel.py", line 1114, in _wait_for_event
    raise e
ssh.SSHException: Channel closed.
Disconnecting from root@server.com... done.
Run Code Online (Sandbox Code Playgroud)

我需要在远程服务器上配置什么才能使用put

Jua*_*hin 8

感谢@Drake我发现sftp远程计算机上的服务器存在问题.

为了测试这个:

$ sftp remote-server
subsystem request failed on channel 0
Couldn't read packet: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)

我读到这是为了启用sftp我需要添加该行

Subsystem sftp /usr/lib/openssh/sftp-server
Run Code Online (Sandbox Code Playgroud)

to /etc/ssh/sshd_config和restart(/etc/init.d/ssh restart)ssh服务.但是这条线已经存在并且无法正常工作.

然后,在阅读http://forums.debian.net/viewtopic.php?f=5&t=42818之后,我改变了那一行

Subsystem sftp internal-sftp
Run Code Online (Sandbox Code Playgroud)

重新启动该ssh服务,它现在正在工作:

$ sftp remote-server
Connected to remote-server
sftp>
Run Code Online (Sandbox Code Playgroud)