{"id":15171823,"url":"https://github.com/alexisbg/ssh-agent-add-id","last_synced_at":"2025-10-26T00:30:51.319Z","repository":{"id":213916576,"uuid":"735138036","full_name":"alexisbg/ssh-agent-add-id","owner":"alexisbg","description":"A wrapper for ssh-add that checks whether a key has already been added to the SSH agent.","archived":false,"fork":false,"pushed_at":"2024-06-14T11:11:27.000Z","size":117,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T12:51:21.114Z","etag":null,"topics":["authentication","ci","gitbucket","github","gitlab","ssh-add","ssh-agent","vscode","vscode-remote","wsl"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexisbg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-23T19:54:39.000Z","updated_at":"2024-12-21T12:27:40.000Z","dependencies_parsed_at":"2024-01-30T15:44:25.723Z","dependency_job_id":"09a180a0-f786-4f32-b059-a3e71fee1df6","html_url":"https://github.com/alexisbg/ssh-agent-add-id","commit_stats":null,"previous_names":["alexisbg/ssh-agent-add-id"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisbg%2Fssh-agent-add-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisbg%2Fssh-agent-add-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisbg%2Fssh-agent-add-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisbg%2Fssh-agent-add-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexisbg","download_url":"https://codeload.github.com/alexisbg/ssh-agent-add-id/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238229940,"owners_count":19437723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","ci","gitbucket","github","gitlab","ssh-add","ssh-agent","vscode","vscode-remote","wsl"],"created_at":"2024-09-27T09:04:09.782Z","updated_at":"2025-10-26T00:30:50.997Z","avatar_url":"https://github.com/alexisbg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ssh-agent-add-id\n\n[![PyPI version](https://img.shields.io/pypi/v/ssh-agent-add-id)](https://pypi.python.org/pypi/ssh-agent-add-id)\n[![Python versions](https://img.shields.io/pypi/pyversions/ssh-agent-add-id)](https://github.com/alexisbg/ssh-agent-add-id)\n\nA wrapper for `ssh-add` that checks whether a key has already been added to the `SSH agent` rather than prompting for the passphrase every time.\n\n\u003cbr /\u003e\n\n## Description\n`ssh-agent-add-id` was primarily created to address a [pending issue](https://github.com/microsoft/vscode-remote-release/issues/2369) in the `VS Code` [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) when authenticating with an SSH key that requires a passphrase, such as for a remote Git repository. If this key has not been previously added to the `SSH agent` accessible from the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl), `VS Code` does not prompt for the passphrase, causing operations like pushing to the remote repository to get stuck.\n\n`ssh-agent-add-id` serves as a wrapper for the [ssh-add](https://man.openbsd.org/ssh-add) command. However, unlike the latter, it does not prompt again for the passphrase and exits quietly if the key has already been added to the SSH agent. It can thus be easily executed in a `VS Code` task when a project is opened. \n\nAnd beyond remote Git repositories and WSL, `ssh-agent-add-id` can be also be used with cloud services that rely on SSH key authentication and thus reduce the number of times you need to enter your passphrases.\n\n\u003cbr /\u003e\n\n## Requirements\n### SSH agent\n- [ssh-add](https://man.openbsd.org/ssh-add) and [ssh-agent](https://man.openbsd.org/ssh-agent) must be installed and running.\n- `SSH_AUTH_SOCK` environment variable needs be set and accessible from `VS Code` environment.\n- For Linux/WSL, in order to share a single `ssh-agent` process for all your shells, it is highly recommended to either run `ssh-agent` as an [user-level systemd service](https://gist.github.com/alexisbg/12102035851c2d0555878cfd865fac75) or to install and setup [Keychain](https://github.com/funtoo/keychain).\n\n### ssh-agent-add-id\n- Requires `Python 3.8+`.\n- It should run smoothly on `macOS` and all `Linux` distributions. However, on `Windows`, it only runs within [WSL](https://learn.microsoft.com/en-us/windows/wsl/).\n\n\u003cbr /\u003e\n\n## Installation\n`ssh-agent-add-id` can be installed using `pip`:\n```\npip install ssh-agent-add-id\n```\n\n### VS Code task\nAdd a task to your VS Code project (in [.vscode/tasks.json](https://github.com/alexisbg/ssh-agent-add-id/blob/main/templates/vs_code/tasks.json)). **Do not forget** to update the `\"args\"` value with the actual path of your private key file:\n```json\n    {\n      \"label\": \"Add Git SSH key to agent\",\n      \"type\": \"shell\",\n      \"command\": \"ssh-agent-add-id\",\n      \"args\": [\"${userHome}/.ssh/\u003cPRIVATE_KEY_FILE\u003e\"],\n      \"presentation\": {\n        \"panel\": \"new\",\n        \"revealProblems\": \"onProblem\",\n        \"close\": true\n      },\n      \"runOptions\": {\n        \"runOn\": \"folderOpen\"\n      },\n      \"problemMatcher\": []\n    }\n```\nThanks to [\"runOptions\"/\"runOn\": \"folderOpen\"](https://code.visualstudio.com/docs/editor/tasks#_run-behavior), this task runs every time your project is opened, launching a new dedicated terminal. If the identity/key was already added to the `SSH agent`, this terminal closes immediately. Otherwise, it prompts for the key passphrase.\n\n\u003cbr /\u003e\n\n## Command line usage\n```\nusage: ssh-agent-add-id [-h] [--version] priv_key_path [pub_key_path]\n\npositional arguments:\n  priv_key_path  the path of the private key file\n  pub_key_path   the path of the public key file in case its filename is not \u003cpriv_key_path\u003e.pub\n\noptional arguments:\n  -h, --help     show this help message and exit\n  --verbose      print some extra info\n  --version      show program's version number and exit\n```\n\n\u003cbr /\u003e\n\n## License\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexisbg%2Fssh-agent-add-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexisbg%2Fssh-agent-add-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexisbg%2Fssh-agent-add-id/lists"}