0

Update: Added output from two more logs, and am now only tailing the last twenty lines...so you can see the relevant lines.


After six months of working perfectly, SFTP on my Ubuntu machine has suddenly stopped working. I never configured or installed it, it just worked.

  • Ubuntu 14.04.1 LTS, GNU bash, version 4.3.11(1)-release (i686-pc-linux-gnu)

The only way I use SFTP is to map my server as a lettered drive on my Windows machine, with SFTP Net Drive Free. As described in painful detail in the post linked above, I've also confirmed that it doesn't work in WebDrive (an SFTP Net Drive competitor) and FileZilla. I've only used SFTP Net Drive, though.

Importantly, I created a new temporary account, and I can SFTP with it, which implies that this is an Ubuntu configuration issue with my current account.

The only customization I've done is to add aliases and alias-like functions to the .bashrc file, and a couple new commands into .inputrc (like here, here, here, and here. If any SFTP-related settings were changed, it was a freak accident.

I've reinstalled SFTP Net Drive, restarted both computers, and still nothing works.

Following the tips in this thread:

Check that (usually at the end, although the order of the configs don't matter) the sftp subsystem is defined in the openssh-server config and not commented out.

cat /etc/ssh/sshd_config
Subsystem sftp /usr/lib/openssh/sftp-server

This is there exactly.

And also check that the file of the subsystem exists

file /usr/lib/openssh/sftp-server
/usr/lib/openssh/sftp-server: ELF 32-bit

My output:

file /usr/lib/openssh/sftp-server
/usr/lib/openssh/sftp-server: ELF 32-bit LSB  shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=469f88be752153898a1e5a4787e6145e6eb99bd3, stripped
history -a

check if the file has the read and executable flags set

ls -l /usr/lib/openssh/sftp-server
-rwxr-xr-x 1 root root 63484 2009-10-22 22:36 /usr/lib/openssh/sftp-server

The permissions are exactly the same.

check the logs for error messages

tail -20 /var/log/auth.log
tail -20 /var/log/messages.log

I attempted to login with SFTP Net Drive at 9:39 pm, and then output the logs.

auth.log:

sudo tail -20 /var/log/auth.log
Jan 14 21:37:18 myservername sudo: pam_unix(sudo:session): session closed for user root
Jan 14 21:38:27 myservername sshd[3068]: Invalid user admin from 123.45.67.891
Jan 14 21:38:27 myservername sshd[3068]: input_userauth_request: invalid user admin [preauth]
Jan 14 21:38:27 myservername sshd[3068]: pam_unix(sshd:auth): check pass; user unknown
Jan 14 21:38:27 myservername sshd[3068]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=li707-40.members.linode.com
Jan 14 21:38:28 myservername sshd[3068]: Failed password for invalid user admin from 123.45.67.891 port 45702 ssh2
Jan 14 21:38:29 myservername sshd[3068]: Received disconnect from 123.45.67.891: 11: Bye Bye [preauth]
Jan 14 21:38:40 myservername sshd[3071]: Accepted password for myusername from 173.61.202.27 port 54007 ssh2
Jan 14 21:38:40 myservername sshd[3071]: pam_unix(sshd:session): session opened for user myusername by (uid=0)
Jan 14 21:38:43 myservername sshd[3071]: pam_unix(sshd:session): session closed for user myusername
Jan 14 21:38:49 myservername sudo:    myusername : TTY=pts/0 ; PWD=/home/myusername ; USER=root ; COMMAND=/usr/bin/tail -50 /var/log/syslog
Jan 14 21:38:49 myservername sudo: pam_unix(sudo:session): session opened for user root by myusername(uid=0)
Jan 14 21:38:49 myservername sudo: pam_unix(sudo:session): session closed for user root
Jan 14 21:40:01 myservername CRON[3151]: pam_unix(cron:session): session opened for user smmsp by (uid=0)
Jan 14 21:40:01 myservername CRON[3151]: pam_unix(cron:session): session closed for user smmsp
Jan 14 21:41:00 myservername sudo:    myusername : TTY=pts/0 ; PWD=/home/myusername ; USER=root ; COMMAND=/usr/bin/tail -20 /var/log/auth.log
Jan 14 21:41:00 myservername sudo: pam_unix(sudo:session): session opened for user root by myusername(uid=0)
Jan 14 21:41:00 myservername sudo: pam_unix(sudo:session): session closed for user root
Jan 14 21:41:17 myservername sudo:    myusername : TTY=pts/0 ; PWD=/home/myusername ; USER=root ; COMMAND=/usr/bin/tail -50 /var/log/auth.log
Jan 14 21:41:17 myservername sudo: pam_unix(sudo:session): session opened for user root by myusername(uid=0)
history -a

sudo tail -20 /var/log/syslog:

sudo tail -20 /var/log/syslog
Jan 14 17:56:39 myservername /usr/sbin/irqbalance: Balancing is ineffective on systems with a single cache domain.  Shutting down
Jan 14 17:56:43 myservername sm-mta[981]: starting daemon (8.14.4): SMTP+queueing@00:10:00
Jan 14 17:56:46 myservername ntpdate[465]: step time server 91.189.89.199 offset 1.521544 sec
Jan 14 17:57:02 myservername ntpdate[1074]: adjust time server 91.189.89.199 offset 0.000019 sec
Jan 14 17:57:59 myservername kernel: [   83.690027] random: nonblocking pool is initialized
Jan 14 18:00:01 myservername CRON[1183]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 18:17:01 myservername CRON[1438]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jan 14 18:20:01 myservername CRON[1536]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 18:40:01 myservername CRON[1971]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 19:00:01 myservername CRON[2086]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 19:17:01 myservername CRON[2187]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jan 14 19:20:01 myservername CRON[2204]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 19:40:01 myservername CRON[2317]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 20:00:01 myservername CRON[2432]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 20:17:01 myservername CRON[2531]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jan 14 20:20:01 myservername CRON[2548]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 20:40:01 myservername CRON[2663]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 21:00:01 myservername CRON[2843]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Jan 14 21:17:01 myservername CRON[2942]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jan 14 21:20:01 myservername CRON[2959]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
history -a

$ sudo tail -20 /var/log/messages.log

sudo tail -20 /var/log/messages.log
tail: cannot open ‘/var/log/messages.log’ for reading: No such file or directory
history -a

I don't know what this means. Accepted password for my account, but not for root. I copy my password from 1Password, paste it into the console and it works. Then paste it into SFTP Net Drive and it doesn't.

I also noticed a "Could not load host key" error earlier in the log, and this page says to execute ssh-keygen -A, which I did. I don't understand if it made a difference.


Is this something I should try to fix? Or should I just "reinstall" SFTP again? (Although I never installed it to begin with.)

1

It turns out that SFTP crashes if any text is output to the console. I added an echo to my ~/.bashrc, which killed it.

I've added the following to the very top of .bashrc:

:<<COMMENT
  SFTP breaks if any thing is output to the shell, and it doesn't need
  anything in .bashrc anyway.

  Description of the following line of code: "If file descriptor 0, or 
  'the input' is connected to a terminal, which is true when you do: 
     ssh yourhost 
  but not when you do:
     ssh yourhost bash -s < script # here it's connected to 'script', a file"

  See
  - https://serverfault.com/questions/485487/use-bashrc-without-breaking-sftp
  - http://www.openssh.com/faq.html#2.9
COMMENT
[ -t 0 ] || return

In addition, I've moved the echo, which I intended as a login intro message, to /etc/motd, as described in this answer


Thanks to dualbus and ishikawa on #bash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.