Fix macOS pssh logging caused by line buffering

Fix macOS pssh logging caused by line buffering

macos homebrew python

If you want to log the output of an SSH connection under macOS with pssh from Homebrew, the following error occurs:

line buffering (buffering=1) isn't supported in binary mode

In the pssh command this happens when you define the -o option for output.

pssh -t 0 -p 10 -l root -h host.list -o logs 'command'

In order to log the output of the SSH session, we have to make a small adjustment to the Python psshlib.

Here is how to fix pssh session logging on macOS Ventura

Let’s open this file with an editor of your choice:

The path may change for you, especially if you have a different version of pssh installed. Just adjust the path to your version number.


Inside the file we search for buffering. Then we change the code as follows.

buffering=1 needs to be changed to buffering=0

At the end of the if else statement, we add the following two lines:


This code block should now look similar to the following code:

    def run(self):
        while True:
            filename, data = self.queue.get()
            if filename == self.ABORT:

            if data == self.OPEN:
                self.files[filename] = open(filename, 'wb', buffering=0)
                dest = self.files[filename]
                if data == self.EOF:

Now we save the file and our changes. From now on pssh can log the output to a file without getting a buffering error message.

Please keep in mind that you may need to make this change again in case you apply a homebrew update on your Mac.

Previous Post Next Post