I faced the same issue of broken ssh scripts.
My solution was to put the following into /etc/gdm3/PostLogin/Default:
#!/bin/sh
if [ ! -e $HOME/.Xauthority ]; then
touch $HOME/.Xauthority
chmod 600 $HOME/.Xauthority
chown $USER.$USER $HOME/.Xauthority
fi
cat $XAUTHORITY > $HOME/.Xauthority
exit 0