Saturday, September 12, 2020

-bash: [: too many arguments When logging on via SSH

 I had an unusual error after creating a CIS Hardened Ubuntu 18.04 image from the Azure Marketplace. As soon as I would log on I would get the error: -bash: [: too many arguments.


I asked the question on EE and this is what we did to find the answer:

I logged on and ran an strace:  strace bash -l 2>output.txt

While that was running I logged on to another session. As soon as I got the error after logging in, I stopped the strace process on the first session.

I opened the output.txt file in Notepad++ and did a search for -bash: [: too many arguments

and found this:

write(2, "/etc/profile: line 22: [: too ma"..., 45/etc/profile: line 22: [: too many arguments
) = 45


I opened /etc/profile and commented out the lines:

#if [ -d /etc/profile.d ]; then
#  for i in /etc/profile.d/*.sh; do
#    if [ -r $i ]; then
#      . $i
#    fi

#  done
#  unset i
#fi
#umask 027

I logged on again and didn't get the error.

What we ended up doing was deleting the file in /etc/profile.d called '*.sh' using; rm -fi '*.sh'



No comments:

Post a Comment

Error 1312 when adding ssl cert

 If you get an error when using netsh to add a cert thumbprint, make sure you have a private key attached to the cert. Also, make sure the c...