zsh: can't write history file /root/.zsh/history

You’ll get this error message on logout when your ssh login is to a userid which may not write your home directory (such as staff_t, when logging into root whose files usually are sysadm_home_r).

Here’s a simple workaround for you zsh users:

if id | grep -q sysadm_r; then
        export SAVEHIST=1500
        export HISTFILE=~/.zsh/history
        export HISTSIZE=1500
fi

This will only enable history when you are sysadm_r.

Bash users probably can use

if ! id | grep -q sysadm_r; then
       shopt -u cmdhist
fi