{"id":22407,"library":"ssh-import-id","title":"ssh-import-id","description":"Authorize SSH public keys from trusted online identities (GitHub, GitLab, Launchpad, etc.). Current version 5.13, with stable release cadence since 2019. Integrated into Ubuntu/Canonical Cloud images for key management.","status":"active","version":"5.13","language":"python","source_language":"en","source_url":"https://github.com/canonical/ssh-import-id","tags":["ssh","authorized_keys","github","launchpad","ubuntu"],"install":[{"cmd":"pip install ssh-import-id","lang":"bash","label":"pip install"}],"dependencies":[],"imports":[{"note":"Use underscores instead of hyphens in Python imports.","wrong":"from ssh-import-id import ...","symbol":"ssh-import-id CLI","correct":"from ssh_import_id import main"},{"note":"Scripts are not Python names; use the module path with underscore.","wrong":"from ssh-import-id-gh import ...","symbol":"ssh-import-id-gh","correct":"from ssh_import_id.gh import main"}],"quickstart":{"code":"import subprocess\nimport os\n# Fetch and add keys from GitHub user 'cmars'\nsubprocess.run(['ssh-import-id', 'gh:cmars'], check=True)\n# Or run from Python with module\nfrom ssh_import_id import main\ntry:\n    main(['gh:cmars'])\nexcept SystemExit as e:\n    print(f'Exited with code {e.code}')","lang":"python","description":"Quickstart: authorize keys from GitHub user 'cmars' using subprocess or the Python module. The CLI is the primary interface."},"warnings":[{"fix":"Use subprocess.run(['ssh-import-id', ...]) for production scripts; wrap main() call in try/except SystemExit if using the library.","message":"The Python module (ssh_import_id) is intended for use as a library but the primary interface is the CLI. Calling main() directly may raise SystemExit on non-zero exit.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure the user exists and has proper directory permissions. Run as the target user or use sudo -u.","message":"ssh-import-id requires the target user to have a home directory and ~/.ssh/authorized_keys file. May fail silently if not present.","severity":"gotcha","affected_versions":"all"},{"fix":"Use --retry N for retries; use --remove to delete keys from specific sources.","message":"The --auto option (automatic retry) and --erase (remove keys from other sources) have been deprecated in version 5.10+.","severity":"deprecated","affected_versions":">=5.10"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install: pip install ssh-import-id. Import: from ssh_import_id import main.","cause":"ssh-import-id is not installed or imported with wrong name (hyphen instead of underscore).","error":"ModuleNotFoundError: No module named 'ssh_import_id'"},{"fix":"Use --retry N instead, e.g., ssh-import-id --retry 3 gh:user.","cause":"The --auto flag was removed in version 5.10.","error":"ssh-import-id: error: unrecognized arguments: --auto"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}