I built this and it looks proper in the terminal... but when I ssh to localhost its just the ansi characters... its garbled and there is no color. Same in iTerm and Terminal. I can cat the file and its fine. Somehow the ssh login breaks it?
Edit: I should add that it does work fine if you place the generated output into /etc/motd instead. The article argues that might not be the best place for it, I'll leave that for you to decide however.