How to get known hosts

2024-05-22 linux

To obtain the value for ssh/.known_hosts. ssh-keyscan command is available.

$ ssh-keyscan foo.example.com
# foo.example.com:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
foo.example.com ssh-rsa AAAAB3NzaC1iGY7ylv8Ry6FveAIh/ocUWnLJrpjr...2/wlrMGtO901oF+zkE+1Cxxr7+jPdf34fyO0...Mk1hsrp0oj69B3tiCYaXZstUTyWHeFCwfI1qff13UGmAs=
# foo.example.com:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
foo.example.com ecdsa-sha2-nistp256 AAAAE2VjZNXNoYTItbmlzdHAyNTY...3QNjiBoHT3SNX4QrFme1r0WgUX8daT8ZwDUfq1aOyDtrM8=
# foo.example.com:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
foo.example.com ssh-ed25519 AAAACNza1lZDI1NTE5...oxxG0armxbTyEoZCsLQwc5r/4
# foo.example.com:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
# foo.example.com:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11

To use on GitHub Actions( shimataro/ssh-key-action@v2 ), only ecdsa-sha2-nistp256 worked(ssh-ed25519 did not work).