amazon-ssm-agent icon indicating copy to clipboard operation
amazon-ssm-agent copied to clipboard

Seamless active directory domain join not working with Ubuntu

Open aacuadras opened this issue 2 years ago • 1 comments

I am trying to join an EC2 instance to active directory through the AWS console. When trying to join the domain, it will error with this message:

/var/lib/amazon/ssm/i-05a2f74fc04941b0e/document/orchestration/23e2b956-6d96-4031-a55e-fb7c240d9d34/2023-11-29T21-35-29.248Z/awsdomainJoin/aws_domainjoin.sh: 737: [: 22.04: unexpected operator
/var/lib/amazon/ssm/i-05a2f74fc04941b0e/document/orchestration/23e2b956-6d96-4031-a55e-fb7c240d9d34/2023-11-29T21-35-29.248Z/awsdomainJoin/aws_domainjoin.sh: 740: [: UBUNTU: unexpected operator

Which seems to be cause by one of the bootstrap scripts. Since the script does a comparison to check if it's an Amazon Linux AMI, I tried joining an Amazon Linux EC2 instance to the domain and it worked.

SSM Agent Version: 3.2.1377.0 OS: Ubuntu 22.04

aacuadras avatar Nov 29 '23 21:11 aacuadras

I saw this issue today as well. The issue has to do with these lines according to the error output:

https://github.com/aws/amazon-ssm-agent/blob/3dee01c80ab7a3d06abc4dbe4648283162bf7516/agent/plugins/domainjoin/domainjoin_unix_script.go#L834 https://github.com/aws/amazon-ssm-agent/blob/3dee01c80ab7a3d06abc4dbe4648283162bf7516/agent/plugins/domainjoin/domainjoin_unix_script.go#L844 https://github.com/aws/amazon-ssm-agent/blob/3dee01c80ab7a3d06abc4dbe4648283162bf7516/agent/plugins/domainjoin/domainjoin_unix_script.go#L847

I believe the problem might be the == comparison operator rather than a single = operator to compare strings. It appears that a single = is used for string comparisons everywhere else in the script. When I cat the script from the error output I see that it starts with #!/bin/sh. I believe == is a non-posix compliant bash syntax that may not work with /bin/sh

aparker-cityworks avatar Feb 18 '25 23:02 aparker-cityworks