Alex's Blog

Alex's Blog

unexpected EF BB BF

#ssh#bom#utf8

Got this little funny hiccup while setting up a remote Ubuntu server.

As soon as I created the user account, I decided to add my public key to authorized_keys so I could log in without password. Since Windows doesn't have ssh-copy-id, I ran this nifty command in PowerShell:

type $env:USERPROFILE\.ssh\id_rsa.pub | ssh {SERVER} "cat >> .ssh/authorized_keys"

My public key was copied to authorized_keys, perfect! But on the next login I still got the password prompt. What the..?

I ran ssh with -vv key to get more info, rechecked everything twice, and finally noticed that the newly added key had some extra characters. And no, these were not CRLF. This time it was a mysterious EF BB BF sequence also known as BOM:

> 00000000: efbb bf73 7368 2d72 7361 2041 4141 4142  ...ssh-rsa AAAAB

After I removed them, ssh recognized my key and everything worked as expected. Don't I just love this stuff!

A couple more useful commands:

xxd myfile # hex dump myfile
diff -y <(xxd myfile1.bin) <(xxd myfile2.bin) # compare binaries

View original post and comments at dev.to →