1

The known_hosts file has entries in the format of:

{server-id} {signature-algorithm} {public-key-string} {comment}

I work with the system that has many machines that share the same {public-key-string} but have many, almost 7000, different {server-ids}, I was wondering is it possible to make entries more compact?

I know I could specify all of them comma-separated like:

{server-id1},{server-id2},... {signature-algorithm} {public-key-string} {comment}

but there are almost 7000 of such {server-ids} with their IPs and aliases.

The naming schema of {server-ids} is something like:

a01b01c01d01
a01b01c01d02
...
a01b01c02d01
...
a08b11c06d12

Is some compact syntax for known_hosts available? Such as:

a[01-08]b[01-11]c[01-06]d[01-12] {signature-algorithm} {public-key-string} {comment}

Can someone tell me how to achieve this?

1 Answer 1

1

Once I submitted the question, I noticed that there is an entry on a similar file (ssh_known_hosts) file in the manual of sshd.

man sshd

The manual states:

Hostnames is a comma-separated list of patterns (‘*’ and ‘?’ act as wildcards); each pattern in turn is matched against the canonical host name (when authenticating a client) or against the user-supplied name (when authenticating a server). A pattern may also be preceded by ‘!’ to indicate negation: if the host name matches a negated pattern, it is not accepted (by that line) even if it matched another pattern on the line. A hostname or address may optionally be enclosed within ‘[’ and ‘]’ brackets then followed by ‘:’ and a non-standard port number.

Since the file format of ssh_known_hosts matches known_hosts, the answer to my question is by using wildcards:

a0?b??c0?d??,192.168.*.* {signature-algorithm} {public-key-string} {comment}

However, this still does not restrict only values I wanted to have, therefore if someone knows how to restrict it further please let me know.

a0?b??c0?d?? can also be a0ibx3c0wdxy

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.