Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use fabric put - Is there any server configuration needed?

I'm using fabric to do a remote deployment of my app on a rackspace server. I've tried my scripts on virtual machines using the same OS (Ubuntu Server 10.04) on my home computer and they all seem to work.

Strangely, all put fabric commands fail on the real server. All other commands (run, cd, sudo, etc) seem to work ok.

This only happens when targeting this specific server, this is the command I execute:

fab test --host remote-server

remote-server is an alias on my .ssh/config. My fabfile:

@task
def test():
    sudo("echo testing")
    put("/tmp/file.txt", "/tmp/")

tmp/test_file.txt is just a text file I'm using for my tests

This is the output

[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 [email protected]... done.

Is there anything I need to configure on the remote server to be able to send files using put?

like image 693
Juan Enrique Muñoz Zolotoochin Avatar asked Apr 19 '12 04:04

Juan Enrique Muñoz Zolotoochin


2 Answers

Thanks to @Drake I found out that there was an issue with the sftp server on the remote machine.

To test for this:

$ sftp remote-server
subsystem request failed on channel 0
Couldn't read packet: Connection reset by peer

I read that in order to enable sftp I needed to add the line

Subsystem sftp /usr/lib/openssh/sftp-server

to /etc/ssh/sshd_config and restart (/etc/init.d/ssh restart) the ssh service. But the line was already there and it wasn't working.

Then, after reading http://forums.debian.net/viewtopic.php?f=5&t=42818, I changed that line for

Subsystem sftp internal-sftp

restarted the ssh service, and it is now working:

$ sftp remote-server
Connected to remote-server
sftp>
like image 123
Juan Enrique Muñoz Zolotoochin Avatar answered Sep 28 '22 08:09

Juan Enrique Muñoz Zolotoochin


I had same issue. I found sftp was not installed on my server. I installed openssh and restarted sshd service.

yum -y install openssh
service sshd restart

Then also i had same issue. I checked the system log /var/log/messages. I found following error

Jul  3 04:23:20 <ip> sshd[13996]: subsystem request for sftp
Jul  3 04:23:20 <ip> sshd[13996]: error: subsystem: cannot stat /usr/libexec/sftp-   server: No such file or directory
Jul  3 04:23:20 <ip> sshd[13996]: subsystem request for sftp failed, subsystem not found

I locate my sftp-server location which was in "/usr/libexec/openssh/sftp-server" and script was looking at "/usr/libexec/sftp-server" location I created symbolic link and my issue got resolved.

root@<ip> fabric]# locate sftp-server
/usr/libexec/openssh/sftp-server
/usr/share/man/man8/sftp-server.8.gz

ln -s /usr/libexec/openssh/sftp-server /usr/libexec/sftp-server
like image 45
Abhijit Avatar answered Sep 28 '22 10:09

Abhijit