Blog

Monday, January 5, 2009

Cannot connect with Capistrano or sFTP on CentOS

If you are trying to do a "get" operation with Capistrano and receive the following error:
/Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:156:in `[]=': undefined method `[]=' for nil:NilClass (NoMethodError)
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:207:in `handle_error'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:48:in `process!'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:43:in `loop'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:43:in `process!'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/transfer.rb:11:in `process'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/configuration/actions/file_transfer.rb:40:in `transfer'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/configuration/connections.rb:170:in `execute_on_servers'
 from /Library/Ruby/Gems/1.8/gems/net-ssh-2.0.3/lib/net/ssh/transport/algorithms.rb:296:in `each_slice'
  ... 17 levels...
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/lib/capistrano/cli/execute.rb:14:in `execute'
 from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.3/bin/cap:4
 from /usr/bin/cap:19:in `load'
 from /usr/bin/cap:19


or a simple sftp connection and get the following error:
Request for subsystem 'sFTP' failed on channel 0

It is likely your sftp server is not running due to a mis-configuration in the /etc/ssh/ssh_config file. For CentOS 5.2 Final on a 64-bit architecture I made the following change:
  # The default is incorrect
  # Subsystem sftp /usr/lib/openssh/sftp-server
  Subsystem sftp /usr/libexec/openssh/sftp-server  

The restart ssh server using:
$ sudo /etc/init.d/sshd restart

Please note this blog is no longer maintained. Please visit CivilCode Inc - Custom Software Development.