ssh-import-id lp:$missing-user attempts to parse the (HTML) 404 response as a series of ssh keys

Bug #1770305 reported by Michael Hudson-Doyle on 2018-05-10
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ssh-import-id
Medium
Michael Hudson-Doyle
ssh-import-id (Ubuntu)
Medium
Unassigned
Bionic
Undecided
Unassigned

Bug Description

[Impact]
Invoking ssh-import-id lp:$missing_user produces unhelpful, noisy error.

I want to change subiquity to invoke ssh-import-id directly and helpful error messages are important in giving useful feedback to the user.

[Test case]
"ssh-import-id lp:mwhudso" should output "no such user" or some similar helpful messsage, not pages of complaints about a file in /tmp not being a public key file.

[Regression potential]
The upload to bionic unapproved is an untested combination of patches so needs careful testing. Fortunately each patch is small and mostly independent so testing each affected area of code should not be too onerous.

[Original description]
mwhudson@ringil:~/src/ssh-import-id/lp-1770302$ ssh-import-id lp:mwhudso
/tmp/ssh-auth-key-check_0bkdmoa.pub is not a public key file.
/tmp/ssh-auth-key-checkjxze5tp8.pub is not a public key file.
[... continues ...]
/tmp/ssh-auth-key-checkqm4_egrs.pub is not a public key file.
/tmp/ssh-auth-key-checkn5yqafje.pub is not a public key file.
2018-05-10 15:13:53,539 INFO [0] SSH keys [Authorized]
2018-05-10 15:13:53,543 ERROR No matching keys found for [lp:mwhudso]

There is no check of the response status code :(

Scott Moser (smoser) on 2018-05-11
Changed in ssh-import-id:
assignee: nobody → Michael Hudson-Doyle (mwhudson)
importance: Undecided → Medium
status: New → Fix Committed
Scott Moser (smoser) on 2018-05-11
Changed in ssh-import-id (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ssh-import-id - 5.7-24-g4001a38e-0ubuntu1

---------------
ssh-import-id (5.7-24-g4001a38e-0ubuntu1) cosmic; urgency=medium

  * New upstream snapshot.
    - debian/postinst: Correctly check old version.
    - debian/: Adjust packaging to include debian's changes and fix
      lintian warnings.
    - Migrate upstream to git.
    - Add running of pycodestyle and pylint via tox and fix warnings.
    - Convert tabs to spaces for indentation globally.
    - Get path to user's authorized_keys even if HOME is not set.
      (LP: #1570997)
    - Exit with sys.exit() rather than os._exit.
      [Michael Hudson-Doyle] (LP: #1770302)
    - Launchpad: check status code of response when fetching ssh keys.
      [Michael Hudson-Doyle] (LP: #1770305)
    - Fix NameError on unknown service/proto. [Michael Hudson-Doyle]
    - debian/rules: no longer run pep8 in debian build.
    - Use setup.py's console_scripts to write ssh-import-id to /usr/bin.

 -- Scott Moser <email address hidden> Fri, 11 May 2018 14:56:46 -0400

Changed in ssh-import-id (Ubuntu):
status: Confirmed → Fix Released
description: updated
description: updated
description: updated

Hello Michael, or anyone else affected,

Accepted ssh-import-id into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ssh-import-id/5.7-0ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in ssh-import-id (Ubuntu Bionic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-bionic
Michael Hudson-Doyle (mwhudson) wrote :

Verification completed, I tested this version:

$ dpkg-query -W ssh-import-id
ssh-import-id 5.7-0ubuntu1.1

on my bionic install, I tested importing keys from an non-existing username

$ ssh-import-id mwhudso
2018-05-20 22:17:21,328 ERROR Launchpad user not found. status_code=404 user=mwhudso

and existing

$ ssh-import-id mwhudson
2018-05-20 22:17:24,662 INFO Already authorized ['2048', 'SHA256:uB6hgZW/Ssz+uwrRo/mqnq5HN1wXzUGVbFKW9tt2WgU', 'canonical', '(RSA)']
2018-05-20 22:17:24,663 INFO [1] SSH keys [Authorized]

and even set up a container to that thought launchpad.net was served by another container to test the "other status code" code path (complete with self-signed certificate fiddling):

root@mitm-victim:~# ssh-import-id lp:mwhudson
2018-05-20 10:14:06,089 ERROR Requesting Launchpad keys failed. status_code=403 user=mwhudson

And everything behaved as expected.

tags: added: verification-done-bionic
removed: verification-needed verification-needed-bionic
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ssh-import-id - 5.7-0ubuntu1.1

---------------
ssh-import-id (5.7-0ubuntu1.1) bionic; urgency=medium

  * Convert source foramt to "3.0 (quilt)", implicitly removing
    ssh_import_id.egg-info presumably included in last upload by
    mistake.
  * Backport some fixes from cosmic:
    - d/patches/0001-lp-1770302-output-flushing.patch: Ensure error
      messages in fetch_keys_gh get flushed by replacing calls to print
      with calls to die and calls to os._exit() with calls to sys.exit.
      (LP: #1770302)
    - d/patches/0002-lp-1770503-launchpad-error-checking.patch: Check
      status code of response when fetching ssh keys from Launchpad.
      (LP: #1770305)
    - d/patches/0003-lp-1570997-find-keys-no-HOME.patch: Get path to
      user's authorized_keys even if HOME is not set. (LP: #1570997)

 -- Michael Hudson-Doyle <email address hidden> Thu, 17 May 2018 11:40:43 +1200

Changed in ssh-import-id (Ubuntu Bionic):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for ssh-import-id has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers