Bug 2413 - Suppress 'Permanently added ... to known hosts' when redirecting to /dev/null
Summary: Suppress 'Permanently added ... to known hosts' when redirecting to /dev/null
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 6.8p1
Hardware: 68k Mac OS X
: P5 trivial
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-12 12:59 AEST by Ben Creasy
Modified: 2023-03-17 13:41 AEDT (History)
3 users (show)

See Also:


Attachments
Accept UserKnownHostsFile=none (3.32 KB, patch)
2015-06-24 10:30 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Creasy 2015-06-12 12:59:56 AEST
See http://superuser.com/a/141352/457084 - it is reasonably common to disable adding to known_hosts (sometimes I know a host just won't be around next time), but it currently outputs 'Warning: Permanently added '104.131.139.183' (RSA) to the list of known hosts' even when that isn't happening. I'm noting this upstream in the interest of correct output.
Comment 1 Darren Tucker 2015-06-16 14:34:08 AEST
Well ssh *is* actually writing it, but it's being immediately discarded outside of ssh's control.

You can already suppress the warning with LogLevel=ERROR as noted in those links and UserKnownHostsFile=/dev/null is a pretty poor practice anyway, so I don't think we should be doing anything to encourage it.
Comment 2 Ben Creasy 2015-06-18 19:12:37 AEST
I see what you mean, and it is true that various workarounds are suggested at http://superuser.com/questions/141344/dont-add-hostkey-to-known-hosts-for-ssh/141352#141352. In terms of what ssh is writing, I would image that ssh can figure out whether the final output is /dev/null (of course the last thing most people want is yet another optional switch). In my case I like being able to have a known_hosts file that has hosts that I expect to connect to more than once - it feels more organized. 

In my case, I'm sometimes starting up temporary DigitalOcean droplets for a little while to test something out and then destroying them. I'd rather not limit my logging or have to mess around with a config file when I do that.

Is there a way to do this which doesn't require tweaking the config files but isn't a poor practice?
Comment 3 Damien Miller 2015-06-24 10:30:13 AEST
Created attachment 2653 [details]
Accept UserKnownHostsFile=none

We could perhaps allow UserKnownHostsFile=none like this diff attempts
Comment 4 Darren Tucker 2023-01-13 13:36:54 AEDT
Looks like "UserKnownHostsFile none" was added back in 8.5 however it's not currently documented.  We'll add this for the next release, which should fully resolve this bug.
Comment 5 Damien Miller 2023-03-17 13:41:13 AEDT
OpenSSH 9.3 has been released. Close resolved bugs