Fish-shell: Rsync and sftp doesn't work when remote host uses fish shell

Created on 18 Oct 2016  ·  3Comments  ·  Source: fish-shell/fish-shell

OS: Debian Jessie
fish: 2.2.0

OS: Maui Linux
fish: 2.3.1

How to reproduce?

  1. set on remote host any script to run on login (script should print any message on command line)
  2. Try to login to remote host via sftp -> Fail
  3. Try to sync any dir via rsync. Rsync should use ssh to sync dir on remote host. -> Fail

When remote host uses fish shell, user can't use rsync and sftp (sftp on command line and inside mc). Remote host uses on login script to show some informations.
Link to script: https://blog.pawel.mydevil.net/index.php/2014/02/20/wyswietlanie-danych-przy-logowaniu-skrypt/

I tested on two hosts. First host is Debian Jessie (fish, version 2.2.0) and second is Maui Linux (fish, version 2.3.1).

sftp
sftp root@remoteHost
root@remoteHost's password:
Received message too long 539831597

part of log auth.log
Accepted password for root from localHost port 48460 ssh2
Oct 18 19:18:59 bpi sshd[7502]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 18 19:19:00 bpi sshd[7502]: Received disconnect from localHost: 11: disconnected by user
Oct 18 19:19:00 bpi sshd[7502]: pam_unix(sshd:session): session closed for user root

rsync:
~ $ sudo rsync -av --delete -e ssh /home/pawel pawel@remoteHost:/mnt/backup
[sudo] hasło użytkownika pawel:
pawel@remoteHost's password:
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(176) [sender=3.1.1]

I read manual and Internet and I executed the command
"ssh pawel@RemoteIP /bin/true > out.dat"
file "out.dat" contain result of script runned on login.

When I comment out link to script in file /etc/fish/config.fish, everything works correctly.

question

Most helpful comment

Works for me. This type of failure is usually caused by the shell config files writing to stdout when the session isn't interactive. In the case of fish you should ensure that anything in your _~/.config/fish/config.fish_ (and scripts it sources) that might write to stdout (or read from stdin but that's less common) is wrapped in a if status --is-interactive ... end block.

All 3 comments

Works for me. This type of failure is usually caused by the shell config files writing to stdout when the session isn't interactive. In the case of fish you should ensure that anything in your _~/.config/fish/config.fish_ (and scripts it sources) that might write to stdout (or read from stdin but that's less common) is wrapped in a if status --is-interactive ... end block.

Thanks a lot for your help. I put something like this

if status --is-interactive
/path/to/script/which/print/on/console
end

into /etc/fish/config.fish and works perfectly. Script is running only when shell is invoked by user, not by script.
I tryed to put "if" inside script,. but I don't know how to mix bash script and fish script.

Why not put this hint to FAQ? I've suffered from this problem for a time, being unable to use rsync with fish shell.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olivergondza picture olivergondza  ·  3Comments

yqiang picture yqiang  ·  3Comments

krader1961 picture krader1961  ·  3Comments

pluckytree picture pluckytree  ·  3Comments

andrewhowdencom picture andrewhowdencom  ·  3Comments