Thank you for taking the time to report this bug while providing a good reproducer.
I was able to reproduce in Focal and Bionic
# ssh-keyscan github.com >test_known_hosts # ls -la test_known_hosts
-rw-r--r-- 1 root root 656 Mar 28 14:24 test_known_hosts
# ssh-keygen -R github.com -f test_known_hosts
test_known_hosts updated. Original contents retained as test_known_hosts.old
# ls -la test_known_hosts -rw------- 1 root root 0 Mar 28 14:25 test_known_hosts
However in Jammy and Impish this is fixed:
-rw-r--r-- 1 root root 656 Mar 28 14:30 test_known_hosts
# ls -la test_known_hosts -rw-r--r-- 1 root root 0 Mar 28 14:31 test_known_hosts
With this already being fixed in the newer releases it should just be a matter of finding the relevant commit and adding it to focal and bionic.
Thanks
Thank you for taking the time to report this bug while providing a good reproducer.
I was able to reproduce in Focal and Bionic
# ssh-keyscan github.com >test_known_hosts
# ls -la test_known_hosts
-rw-r--r-- 1 root root 656 Mar 28 14:24 test_known_hosts
# ssh-keygen -R github.com -f test_known_hosts
test_known_hosts updated. hosts.old
Original contents retained as test_known_
# ls -la test_known_hosts
-rw------- 1 root root 0 Mar 28 14:25 test_known_hosts
However in Jammy and Impish this is fixed:
# ssh-keyscan github.com >test_known_hosts
# ls -la test_known_hosts
-rw-r--r-- 1 root root 656 Mar 28 14:30 test_known_hosts
# ssh-keygen -R github.com -f test_known_hosts
test_known_hosts updated. hosts.old
Original contents retained as test_known_
# ls -la test_known_hosts
-rw-r--r-- 1 root root 0 Mar 28 14:31 test_known_hosts
With this already being fixed in the newer releases it should just be a matter of finding the relevant commit and adding it to focal and bionic.
Thanks