Aws-cli: `send-ssh-public-key` incorrectly recognises the public key length as 27 bytes, when it is 256 bytes

Created on 19 Apr 2020  Â·  2Comments  Â·  Source: aws/aws-cli

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug

aws ec2-instance-connect send-ssh-public-key incorrectly recognises the public key length as 27 bytes, when it is 256 bytes

SDK version number

2.0.8 per:

➜  networky git:(ec2-access) ✗ aws --version
aws-cli/2.0.8 Python/3.8.2 Darwin/19.4.0 botocore/2.0.0dev12

Platform/OS/Hardware/Device

Mac OS X Catalina

To Reproduce (observed behavior)

➜  networky git:(ec2-access) ✗ make connect-neptune-proxy
aws ec2-instance-connect send-ssh-public-key --instance-id i-0e5ad6adb8f5f3335 --availability-zone eu-west-2a --instance-os-user ec2-user --ssh-public-key ~/.ssh/id_rsa.pub

Parameter validation failed:
Invalid length for parameter SSHPublicKey, value: 27, valid range: 256-inf
make: *** [connect-neptune-proxy] Error 252
➜  networky git:(ec2-access) ✗ ssh-keygen -lf ~/.ssh/id_rsa.pub
2048 SHA256:wQzPTplSAB7p8rXGcOWxcbF/AOnYc4+bsmNaFcxAf9o [email protected] (RSA)

Expected behavior

I expect my public key to be successfully pushed to the EC2 instance.

Logs/output

➜  networky git:(ec2-access) ✗ make connect-neptune-proxy      
aws ec2-instance-connect send-ssh-public-key --debug --instance-id i-0e5ad6adb8f5f3335 --availability-zone eu-west-2a --instance-os-user ec2-user --ssh-public-key ~/.ssh/id_rsa.pub
2020-04-19 19:36:55,318 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.0.8 Python/3.8.2 Darwin/19.4.0 botocore/2.0.0dev12
2020-04-19 19:36:55,318 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['ec2-instance-connect', 'send-ssh-public-key', '--debug', '--instance-id', 'i-0e5ad6adb8f5f3335', '--availability-zone', 'eu-west-2a', '--instance-os-user', 'ec2-user', '--ssh-public-key', '/Users/kkom/.ssh/id_rsa.pub']
2020-04-19 19:36:55,318 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_timestamp_parser at 0x111092280>
2020-04-19 19:36:55,318 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x110819160>
2020-04-19 19:36:55,318 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_binary_formatter at 0x1110dd940>
2020-04-19 19:36:55,318 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x1108449d0>
2020-04-19 19:36:55,328 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x110f51b80>
2020-04-19 19:36:55,328 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_json_file_cache at 0x110efdd30>
2020-04-19 19:36:55,346 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/data/ec2-instance-connect/2018-04-02/service-2.json
2020-04-19 19:36:55,346 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ec2-instance-connect: calling handler <function add_waiters at 0x11109b8b0>
2020-04-19 19:36:55,367 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('instance-id', <awscli.arguments.CLIArgument object at 0x11113e640>), ('instance-os-user', <awscli.arguments.CLIArgument object at 0x11113e550>), ('ssh-public-key', <awscli.arguments.CLIArgument object at 0x11113e700>), ('availability-zone', <awscli.arguments.CLIArgument object at 0x11113e6d0>)])
2020-04-19 19:36:55,367 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2-instance-connect.send-ssh-public-key: calling handler <function add_streaming_output_arg at 0x111092820>
2020-04-19 19:36:55,367 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2-instance-connect.send-ssh-public-key: calling handler <function add_cli_input_json at 0x110848280>
2020-04-19 19:36:55,367 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2-instance-connect.send-ssh-public-key: calling handler <function add_cli_input_yaml at 0x110848550>
2020-04-19 19:36:55,367 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2-instance-connect.send-ssh-public-key: calling handler <function unify_paging_params at 0x110f0b4c0>
2020-04-19 19:36:55,393 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/data/ec2-instance-connect/2018-04-02/paginators-1.json
2020-04-19 19:36:55,394 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2-instance-connect.send-ssh-public-key: calling handler <function add_generate_skeleton at 0x110ffe040>
2020-04-19 19:36:55,394 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2-instance-connect.send-ssh-public-key: calling handler <function add_auto_prompt at 0x1110dd8b0>
2020-04-19 19:36:55,394 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2-instance-connect.send-ssh-public-key: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x11113e3a0>>
2020-04-19 19:36:55,394 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2-instance-connect.send-ssh-public-key: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x11113e160>>
2020-04-19 19:36:55,407 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2-instance-connect.send-ssh-public-key: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x11113e1f0>>
2020-04-19 19:36:55,407 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2-instance-connect.send-ssh-public-key: calling handler <bound method AutoPromptArgument.override_required_args of <awscli.customizations.autoprompt.AutoPromptArgument object at 0x11113e280>>
2020-04-19 19:36:55,409 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.instance-id: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,409 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.ec2-instance-connect.send-ssh-public-key: calling handler <awscli.argprocess.ParamShorthandParser object at 0x11080bf70>
2020-04-19 19:36:55,409 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'i-0e5ad6adb8f5f3335' for parameter "instance_id": 'i-0e5ad6adb8f5f3335'
2020-04-19 19:36:55,409 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.instance-os-user: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,410 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.ec2-instance-connect.send-ssh-public-key: calling handler <awscli.argprocess.ParamShorthandParser object at 0x11080bf70>
2020-04-19 19:36:55,410 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'ec2-user' for parameter "instance_os_user": 'ec2-user'
2020-04-19 19:36:55,410 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.ssh-public-key: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,410 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.ec2-instance-connect.send-ssh-public-key: calling handler <awscli.argprocess.ParamShorthandParser object at 0x11080bf70>
2020-04-19 19:36:55,410 - MainThread - awscli.arguments - DEBUG - Unpacked value of '/Users/kkom/.ssh/id_rsa.pub' for parameter "ssh_public_key": '/Users/kkom/.ssh/id_rsa.pub'
2020-04-19 19:36:55,410 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.availability-zone: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,410 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.ec2-instance-connect.send-ssh-public-key: calling handler <awscli.argprocess.ParamShorthandParser object at 0x11080bf70>
2020-04-19 19:36:55,410 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'eu-west-2a' for parameter "availability_zone": 'eu-west-2a'
2020-04-19 19:36:55,411 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,411 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.cli-input-yaml: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,411 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,411 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2-instance-connect.send-ssh-public-key.cli-auto-prompt: calling handler <awscli.paramfile.URIArgumentHandler object at 0x11114aca0>
2020-04-19 19:36:55,411 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2-instance-connect.send-ssh-public-key: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x11113e3a0>>
2020-04-19 19:36:55,412 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2-instance-connect.send-ssh-public-key: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x11113e160>>
2020-04-19 19:36:55,412 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2-instance-connect.send-ssh-public-key: calling handler <bound method GenerateCliSkeletonArgument.generate_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x11113e1f0>>
2020-04-19 19:36:55,412 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2-instance-connect.send-ssh-public-key: calling handler <bound method AutoPromptArgument.auto_prompt_arguments of <awscli.customizations.autoprompt.AutoPromptArgument object at 0x11113e280>>
2020-04-19 19:36:55,412 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2020-04-19 19:36:55,412 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2020-04-19 19:36:55,412 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2020-04-19 19:36:55,412 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso
2020-04-19 19:36:55,412 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2020-04-19 19:36:55,413 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials
2020-04-19 19:36:55,415 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/data/endpoints.json
2020-04-19 19:36:55,425 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x1101bb1f0>
2020-04-19 19:36:55,425 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.ec2-instance-connect: calling handler <function add_generate_presigned_url at 0x110185af0>
2020-04-19 19:36:55,425 - MainThread - botocore.regions - DEBUG - Creating a regex based endpoint for ec2-instance-connect, eu-west-2
2020-04-19 19:36:55,431 - MainThread - botocore.endpoint - DEBUG - Setting ec2-instance-connect timeout as (60, 60)
2020-04-19 19:36:55,432 - MainThread - botocore.hooks - DEBUG - Event provide-client-params.ec2-instance-connect.SendSSHPublicKey: calling handler <function base64_decode_input_blobs at 0x1110e11f0>
2020-04-19 19:36:55,432 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.ec2-instance-connect.SendSSHPublicKey: calling handler <function generate_idempotent_uuid at 0x1101d6310>
2020-04-19 19:36:55,432 - MainThread - awscli.clidriver - DEBUG - Client side parameter validation failed
Traceback (most recent call last):
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 335, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 507, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 682, in __call__
    return self._operation_caller.invoke(
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 805, in invoke
    response = self._make_client_call(
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 817, in _make_client_call
    response = getattr(client, xform_name(operation_name))(
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/client.py", line 208, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/client.py", line 490, in _make_api_call
    request_dict = self._convert_to_request_dict(
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/client.py", line 538, in _convert_to_request_dict
    request_dict = self._serializer.serialize_to_request(
  File "/usr/local/Cellar/awscli/2.0.8/libexec/lib/python3.8/site-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid length for parameter SSHPublicKey, value: 27, valid range: 256-inf

Parameter validation failed:
Invalid length for parameter SSHPublicKey, value: 27, valid range: 256-inf
make: *** [connect-neptune-proxy] Error 252

Additional context

The only similar issues I could find are not related to SSH key length:

https://github.com/aws/aws-cli/issues/2338
https://github.com/aws/aws-cli/issues/2337

needs-triage

Most helpful comment

nevermind, I forgot to pass the file:// prefix - my bad!

All 2 comments

nevermind, I forgot to pass the file:// prefix - my bad!

follow the steps given in this forum. https://devopsforum.info/viewtopic.php?f=51&t=2447

Was this page helpful?
0 / 5 - 0 ratings