When calling base64 <<< username:password I get this result: dXNlcm5hbWU6cGFzc3dvcmQK.
When using that result in PostMan and issuing a request against a Basic Auth endpoint, I get back a 401.
When encoding username:password at https://www.base64encode.org, I get back this result: dXNlcm5hbWU6cGFzc3dvcmQ= and I can successfully use it against the Basic Auth endpoint from above.
If I use PostMan to generate the Basic Auth header passing in username and password, it generates the same base64 encoded string as https://www.base64encode.org.
I could also copy username:password into testin.txt and use openssl to create the base64 string:
openssl base64 -in testin.txt -out testout.txt returns dXNlcm5hbWU6cGFzc3dvcmQK which is the same wrong result as base64 creates.
openssl version returns OpenSSL 0.9.8zh 14 Jan 2016
Decoding
dXNlcm5hbWU6cGFzc3dvcmQKgivesusername:password\n.So my guess is that in both cases, you have a linefeed you weren't expecting. The
testin.txtcase is easy to solve (modify file, remove linefeed).I expect the base64 case can be solved by using echo with the -n parameter to remove the linefeed: