Bug 2903

Summary: ssh-keyscan returns '0' when no keys are found
Product: Portable OpenSSH Reporter: Robert Grizzell <robert>
Component: ssh-keyscanAssignee: Damien Miller <djm>
Status: CLOSED FIXED    
Severity: normal CC: ahmedsayeed1982, djm, dtucker
Priority: P5    
Version: 7.6p1   
Hardware: amd64   
OS: Linux   
Bug Depends on:    
Bug Blocks: 2915    
Attachments:
Description Flags
exit with status 1 if no keys found dtucker: ok+

Description Robert Grizzell 2018-09-09 15:44:28 AEST
ssh-keyscan returns with an exit status of '0' when DNS resolution of a domain fails or an SSH connection can't be made. In instances where scripting is involved, this leads to situations where there is no indication that the command completed successfully. Authors are then forced to capture and parse the output in order to test for a successful run.

DNS Resolution:
> ssh-keyscan shouldnotresolve.example
> echo $?
0


No SSH Service:
> ssh-keyscan example.com
> echo $?
0
Comment 1 Damien Miller 2019-01-23 20:32:08 AEDT
Created attachment 3229 [details]
exit with status 1 if no keys found
Comment 2 Damien Miller 2019-01-27 21:54:52 AEDT
This has been committed and will be in openssh-8.0
Comment 3 Damien Miller 2019-10-09 15:11:47 AEDT
Close bugs fixed in openssh-8.1 release cycle
Comment 4 Ahmed Sayeed 2021-10-14 01:43:00 AEDT
[spam removed]