Skip to content

mssh does not correctly handle commands written by Ansible #24

@crestonbunch

Description

@crestonbunch

Here is a minimum reproducible command (fill in INSTANCE_ID and IP_ADDRESS). This command is something Ansible uses to test SSH connections (this works when using the ssh binary instead):

mssh \
  -t ${INSTANCE_ID} \
  -l ubuntu \
  ${IP_ADDRESS} \
  '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo ~/.ansible/tmp `"&& mkdir "` echo ~/.ansible/tmp/ansible-tmp-1623369896.6943882-14170-58937873873026 `" && echo ansible-tmp-1623369896.6943882-14170-58937873873026="` echo ~/.ansible/tmp/ansible-tmp-1623369896.6943882-14170-58937873873026 `" ) && sleep 0'"'"''

Output:

bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `/bin/sh -c ( umask 77 && mkdir -p "` echo ~/.ansible/tmp `"&& mkdir "` echo ~/.ansible/tmp/ansible-tmp-1623369896.6943882-14170-58937873873026 `" && echo ansible-tmp-1623369896.6943882-14170-58937873873026="` echo ~/.ansible/tmp/ansible-tmp-1623369896.6943882-14170-58937873873026 `" ) && sleep 0'

With the -d flag we see the SSH command:

2021-06-10 20:14:24,264 - EC2InstanceConnect - DEBUG - Generated command: ssh -o "IdentitiesOnly=yes" -i /tmp/tmp2jdzw7dw -l ubuntu ubuntu@10.0.2.26 /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp `"&& mkdir "` echo ~/.ansible/tmp/ansible-tmp-1623369896.6943882-14170-58937873873026 `" && echo ansible-tmp-1623369896.6943882-14170-58937873873026="` echo ~/.ansible/tmp/ansible-tmp-1623369896.6943882-14170-58937873873026 `" ) && sleep 0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions