ホストエイリアスを使用した AWS SSM SSH が期待どおりに動作しない

ホストエイリアスを使用した AWS SSM SSH が期待どおりに動作しない

このコマンドがなぜ機能するのか疑問に思います(1):

ssh -i .ssh/my-dev.pem ubuntu@i-1234abc

しかし、このコマンドは以下のエラーで失敗します (2)。

ssh myec2

エラーは次のとおりです:

An error occurred (TargetNotConnected) when calling the StartSession operation: myec2 is not connected.
Connection closed by UNKNOWN port 65535

これは私の.ssh/config

Host myec2
    User ubuntu
    HostName i-1234abc
    IdentityFile ~/.ssh/my-dev.pem
    ProxyCommand sh -c "aws --profile myawsprofile --region us-east-1 ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
 
Host i-* mi-*
    IdentityFile ~/.ssh/my-dev.pem
    ProxyCommand sh -c "aws --profile myawsprofile --region us-east-1 ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"

上記の設定でコマンド (2) を実行すると、私の理解では、コマンド (1) と同じになるはずです。だから、私が理解していないことがあります。

関連情報