Ssh Zfs Cat (bad magic number)

2023-07-27 • 1 min read • Tags: Comp Sysadm Zfs Freebsd

Problem

ssh remote zfs send zroot/some@snap | zfs receive fails with

cannot receive: invalid stream (bad magic number)

Solution

The solution is to use the real ssh executable instead: /usr/bin/ssh ….

Explanation

The invoked ssh is not the ssh binary you expect.

To illustrate further, try ssh cat somefile > /tmp/somefile and you will see that the resulting local file is different than the original file.

Similarly to this person on StackOverflow, I had an ssh() function defined in my .zshrc to update the terminal title with escape characters. Something like print -nR $'\033k'$title$'\033'\\.