{
    "content": [
        {
            "type": "text",
            "text": "# ssh-keyscan (man)\n\n## NAME\n\nssh-keyscan — gather SSH public keys from servers\n\n## SYNOPSIS\n\nssh-keyscan [-46cDHv] [-f file] [-p port] [-T timeout] [-t type] [host | addrlist namelist]\n\n## DESCRIPTION\n\nssh-keyscan is a utility for gathering the public SSH host keys of a number of hosts.  It was\ndesigned to aid in building and verifying sshknownhosts files, the format of which is docu‐\nmented in sshd(8).  ssh-keyscan provides a minimal interface suitable for use by shell and perl\nscripts.\n\n## TLDR\n\n> Get the public SSH keys of remote hosts.\n\n- Retrieve all public SSH keys of a remote host:\n  `ssh-keyscan {{hostname}}`\n- Retrieve all public SSH keys of a remote host listening on a specific port:\n  `ssh-keyscan -p {{port}} {{hostname}}`\n- Retrieve certain types of public SSH keys of a remote host:\n  `ssh-keyscan -t {{rsa,dsa,ecdsa,ed25519}} {{hostname}}`\n- Manually update the SSH known_hosts file with the fingerprint of a given host:\n  `ssh-keyscan -H {{hostname}} >> ~/.ssh/known_hosts`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (10 subsections)\n- **FILES**\n- **EXAMPLES**\n- **SEE ALSO**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "ssh-keyscan",
        "section": "",
        "mode": "man",
        "summary": "ssh-keyscan — gather SSH public keys from servers",
        "synopsis": "ssh-keyscan [-46cDHv] [-f file] [-p port] [-T timeout] [-t type] [host | addrlist namelist]",
        "tldr_summary": "Get the public SSH keys of remote hosts.",
        "tldr_examples": [
            {
                "description": "Retrieve all public SSH keys of a remote host",
                "command": "ssh-keyscan {{hostname}}"
            },
            {
                "description": "Retrieve all public SSH keys of a remote host listening on a specific port",
                "command": "ssh-keyscan -p {{port}} {{hostname}}"
            },
            {
                "description": "Retrieve certain types of public SSH keys of a remote host",
                "command": "ssh-keyscan -t {{rsa,dsa,ecdsa,ed25519}} {{hostname}}"
            },
            {
                "description": "Manually update the SSH known_hosts file with the fingerprint of a given host",
                "command": "ssh-keyscan -H {{hostname}} >> ~/.ssh/known_hosts"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-4",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-6",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-c",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-D",
                "long": null,
                "arg": null,
                "description": "as a ssh(1) knownhosts file."
            },
            {
                "flag": "-f",
                "long": null,
                "arg": null,
                "description": "Read hosts or “addrlist namelist” pairs from file, one per line. If ‘-’ is supplied instead of a filename, ssh-keyscan will read from the standard input. Input is ex‐ pected in the format: 1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4"
            },
            {
                "flag": "-H",
                "long": null,
                "arg": null,
                "description": "ssh(1) and sshd(8), but they do not reveal identifying information should the file's contents be disclosed."
            },
            {
                "flag": "-p",
                "long": null,
                "arg": null,
                "description": "Connect to port on the remote host."
            },
            {
                "flag": "-T",
                "long": null,
                "arg": null,
                "description": "Set the timeout for connection attempts. If timeout seconds have elapsed since a con‐ nection was initiated to a host or since the last time anything was read from that host, the connection is closed and the host in question considered unavailable. The default is 5 seconds."
            },
            {
                "flag": "-t",
                "long": null,
                "arg": null,
                "description": "Specify the type of the key to fetch from the scanned hosts. The possible values are “dsa”, “ecdsa”, “ed25519”, or “rsa”. Multiple values may be specified by separating them with commas. The default is to fetch “rsa”, “ecdsa”, and “ed25519” keys."
            },
            {
                "flag": "-v",
                "long": null,
                "arg": null,
                "description": "If an sshknownhosts file is constructed using ssh-keyscan without verifying the keys, users will be vulnerable to man in the middle attacks. On the other hand, if the security model al‐ lows such a risk, ssh-keyscan can help in the detection of tampered keyfiles or man in the mid‐ dle attacks which have begun after the sshknownhosts file was created."
            }
        ],
        "examples": [
            "Print the RSA host key for machine hostname:",
            "$ ssh-keyscan -t rsa hostname",
            "Find all hosts from the file sshhosts which have new or different keys from those in the",
            "sorted file sshknownhosts:",
            "$ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f sshhosts | \\",
            "sort -u - sshknownhosts | diff sshknownhosts -"
        ],
        "see_also": [
            {
                "name": "ssh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ssh/1/json"
            },
            {
                "name": "sshd",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/sshd/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 13,
                "subsections": [
                    {
                        "name": "-4",
                        "lines": 1,
                        "flag": "-4"
                    },
                    {
                        "name": "-6",
                        "lines": 1,
                        "flag": "-6"
                    },
                    {
                        "name": "-c",
                        "lines": 1,
                        "flag": "-c"
                    },
                    {
                        "name": "-D",
                        "lines": 2,
                        "flag": "-D"
                    },
                    {
                        "name": "-f",
                        "lines": 6,
                        "flag": "-f"
                    },
                    {
                        "name": "-H",
                        "lines": 3,
                        "flag": "-H"
                    },
                    {
                        "name": "-p",
                        "lines": 2,
                        "flag": "-p"
                    },
                    {
                        "name": "-T",
                        "lines": 5,
                        "flag": "-T"
                    },
                    {
                        "name": "-t",
                        "lines": 4,
                        "flag": "-t"
                    },
                    {
                        "name": "-v",
                        "lines": 5,
                        "flag": "-v"
                    }
                ]
            },
            {
                "name": "FILES",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ssh-keyscan — gather SSH public keys from servers\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "ssh-keyscan [-46cDHv] [-f file] [-p port] [-T timeout] [-t type] [host | addrlist namelist]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "ssh-keyscan is a utility for gathering the public SSH host keys of a number of hosts.  It was\ndesigned to aid in building and verifying sshknownhosts files, the format of which is docu‐\nmented in sshd(8).  ssh-keyscan provides a minimal interface suitable for use by shell and perl\nscripts.\n\nssh-keyscan uses non-blocking socket I/O to contact as many hosts as possible in parallel, so\nit is very efficient.  The keys from a domain of 1,000 hosts can be collected in tens of sec‐\nonds, even when some of those hosts are down or do not run sshd(8).  For scanning, one does not\nneed login access to the machines that are being scanned, nor does the scanning process involve\nany encryption.\n\nThe options are as follows:\n",
                "subsections": [
                    {
                        "name": "-4",
                        "content": "",
                        "flag": "-4"
                    },
                    {
                        "name": "-6",
                        "content": "",
                        "flag": "-6"
                    },
                    {
                        "name": "-c",
                        "content": "",
                        "flag": "-c"
                    },
                    {
                        "name": "-D",
                        "content": "as a ssh(1) knownhosts file.\n",
                        "flag": "-D"
                    },
                    {
                        "name": "-f",
                        "content": "Read hosts or “addrlist namelist” pairs from file, one per line.  If ‘-’ is supplied\ninstead of a filename, ssh-keyscan will read from the standard input.  Input is ex‐\npected in the format:\n\n1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4\n",
                        "flag": "-f"
                    },
                    {
                        "name": "-H",
                        "content": "ssh(1) and sshd(8), but they do not reveal identifying information should the file's\ncontents be disclosed.\n",
                        "flag": "-H"
                    },
                    {
                        "name": "-p",
                        "content": "Connect to port on the remote host.\n",
                        "flag": "-p"
                    },
                    {
                        "name": "-T",
                        "content": "Set the timeout for connection attempts.  If timeout seconds have elapsed since a con‐\nnection was initiated to a host or since the last time anything was read from that\nhost, the connection is closed and the host in question considered unavailable.  The\ndefault is 5 seconds.\n",
                        "flag": "-T"
                    },
                    {
                        "name": "-t",
                        "content": "Specify the type of the key to fetch from the scanned hosts.  The possible values are\n“dsa”, “ecdsa”, “ed25519”, or “rsa”.  Multiple values may be specified by separating\nthem with commas.  The default is to fetch “rsa”, “ecdsa”, and “ed25519” keys.\n",
                        "flag": "-t"
                    },
                    {
                        "name": "-v",
                        "content": "If an sshknownhosts file is constructed using ssh-keyscan without verifying the keys, users\nwill be vulnerable to man in the middle attacks.  On the other hand, if the security model al‐\nlows such a risk, ssh-keyscan can help in the detection of tampered keyfiles or man in the mid‐\ndle attacks which have begun after the sshknownhosts file was created.\n",
                        "flag": "-v"
                    }
                ]
            },
            "FILES": {
                "content": "/etc/ssh/sshknownhosts\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "Print the RSA host key for machine hostname:\n\n$ ssh-keyscan -t rsa hostname\n\nFind all hosts from the file sshhosts which have new or different keys from those in the\nsorted file sshknownhosts:\n\n$ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f sshhosts | \\\nsort -u - sshknownhosts | diff sshknownhosts -\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "ssh(1), sshd(8)\n\nUsing DNS to Securely Publish Secure Shell (SSH) Key Fingerprints, RFC 4255, 2006.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "David Mazieres <dm@lcs.mit.edu> wrote the initial version, and Wayne Davison\n<wayned@users.sourceforge.net> added support for protocol version 2.\n\nBSD                            November 30, 2019                           BSD",
                "subsections": []
            }
        }
    }
}