Differences

This shows you the differences between the selected revisions of the page.

2021-01-08 2022-04-04
link update (martin) ec now has web-based console too (martin)
Line 16: Line 16:
  * Host name: Check //Public %%DNS%%// column on //Instances// page of Amazon EC2 console. Note that the public DNS may change when instance is restarted.   * Host name: Check //Public %%DNS%%// column on //Instances// page of Amazon EC2 console. Note that the public DNS may change when instance is restarted.
  * Host key fingerprint: On the first connect you will be prompted to [[ssh_verifying_the_host_key|verify server host key]].   * Host key fingerprint: On the first connect you will be prompted to [[ssh_verifying_the_host_key|verify server host key]].
-    * You can locate key fingerprint in server's initial start log, when host keys are generated.((Using ''cloud-init'' script.)) Use //Actions > Instance Settings > Get System Log// command on //Instances// page of Amazon EC2 console: \\ \\ &screenshotpict(ec2_hostkey) \\ \\ The format of host key display in the log may differ with distribution or its version. \\ Alternatively use ''[[https://docs.aws.amazon.com/cli/latest/reference/ec2/get-console-output.html|aws ec2 get-console-output]]'' command+    * To securely acquire a fingerprint of the host key, use EC2 web-based terminal. Go to //Actions > Connect > EC2 Instance Connect > Connect// on //Instances// page of Amazon EC2 console. In the terminal, use ''[[https://man.openbsd.org/ssh-keygen|ssh-keygen]]'' command to display a fingerprint of any number of host keys algorithms. The following example shows SHA-256 and MD5 fingerprints of Ed25519 hostkey: \\ <code>sudo ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key 
-   * If you did not save the fingerprint on the first instance run, but you have another EC2 instance that you can connect to safely (you know its fingerprints), you can connect to the target instance using private IP from the trusted instance. Staying within private Amazon network keeps you safe from [[wp>Man-in-the-middle_attack|man-in-the-middle attacks]]. When on the trusted instance terminal, you can use following commands to collect fingerprints: \\ <code> +sudo ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key -E md5
-$ ssh-keyscan &lt;target_instance_private_ip&gt; &gt; ec2key +
-$ ssh-keygen -l -f ec2key +
-256 SHA256:oZHeiMEPLKetRgd3M5Itgwaqr2zJJH93EvSdx5UoHbQ &lt;ip> (ED25519) +
-2048 SHA256:8zg105EUFFrPFpVzdfTGsgXnxuSpTiQd85k0uNapUio <ip> (RSA) +
-256 SHA256:L7UXLw0djE5B9W7ZhvrkYVSTZyi1MEQ2dBaRtpkkUGY <ip> (ECDSA)+
</code> </code>
-    * If you do not have another trusted instance, you can create new temporary instance, just for the purpose of collecting the keys. First find keys for the new temporary instance, using it's initial start log. Then collect keys of the target instance by connecting to it from the temporary instance. After that you can discard the temporary instance. 
~~AD~~ ~~AD~~

Last modified: by martin