{"id":20169398,"url":"https://github.com/delphinus/gosshauth","last_synced_at":"2026-05-06T00:07:10.066Z","repository":{"id":64306360,"uuid":"141387752","full_name":"delphinus/gosshauth","owner":"delphinus","description":"A tiny hook tool for bash/zsh to re-authenticate with ssh-agent.","archived":false,"fork":false,"pushed_at":"2019-12-17T05:27:23.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-01T01:58:55.883Z","etag":null,"topics":["bash","ssh","ssh-agent","zsh"],"latest_commit_sha":null,"homepage":"","language":"Go","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/delphinus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-18T05:59:22.000Z","updated_at":"2022-02-11T13:04:14.000Z","dependencies_parsed_at":"2023-01-15T10:45:22.128Z","dependency_job_id":null,"html_url":"https://github.com/delphinus/gosshauth","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/delphinus/gosshauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delphinus%2Fgosshauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delphinus%2Fgosshauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delphinus%2Fgosshauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delphinus%2Fgosshauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delphinus","download_url":"https://codeload.github.com/delphinus/gosshauth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delphinus%2Fgosshauth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32672688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bash","ssh","ssh-agent","zsh"],"created_at":"2024-11-14T01:12:22.622Z","updated_at":"2026-05-06T00:07:10.046Z","avatar_url":"https://github.com/delphinus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `gosshauth`\n\nA tiny hook tool for bash/zsh to re-authenticate with ssh-agent.\n\n## What's this?\n\nThis small command manages sockets for SSH authentication created by\n`ssh-agent`.  It automatically detects the valid socket and rewrite the symlink\nto avoid disconnecting.\n\n## When do I need this?\n\n`ssh-agent` stores the path for sockets into `$SSH_AUTH_SOCK`.  It is a path\nbelow, for instance.\n\n```sh\n# example in macOS\n$ echo $SSH_AUTH_SOCK\n/private/tmp/com.apple.launchd.sa197Z7kVN/Listeners\n```\n\nThis changes every time you login and `ssh-agent` detects the changes and makes\n`$SSH_AUTH_SOCK` indicate validly.  Usually that's enough.\n\nBut when you use terminal multiplexers -- `tmux`, `screen`, or so --, it breaks\nthis.\n\n## Reproducible way\n\n1. Login your Mac.\n  - `$SSH_AUTH_SOCK` is `/some/path/to/Listeners`.\n2. SSH into a Linux box.\n  - `$SSH_AUTH_SOCK` will be changed into `/tmp/path/to/agent.foo`.\n3. Launch `tmux` in the box.  Also you can use SSH authentication in `tmux` by\n   `ssh-agent`.\n4. Detach `tmux` and logout the box.\n5. SSH into the box again.\n  - `$SSH_AUTH_SOCK` will be changed into `/tmp/path/to/agent.bar`.\n6. Attach the existent `tmux` session.\n7. `$SSH_AUTH_SOCK` will be `/tmp/path/to/ssh-agent.foo`, not `...bar`.\n   You can NOT use SSH authentcation in it.\n\n## Solution\n\nHere is `gosshauth`.  You can install this from [release page][] or a command\nbelow.\n\n[release page]: https://github.com/delphinus/gosshauth/releases\n\n```sh\ngo get github.com/delphinus/gosshauth\n```\n\nAnd you should set the hook for zsh/bash.\n\n```bash\n# for bash\nif which gosshauth \u003e /dev/null 2\u003e\u00261; then\n  eval \"$(gosshauth hook bash)\"\nfi\n```\n\n```zsh\n# for zsh\nif (( $+commands[gosshauth] )); then\n  eval \"$(gosshauth hook zsh)\"\nfi\n```\n\n```fish\n# for fish\nif type -q gosshauth\n  gosshauth hook fish | source\nend\n```\n\nNow you can use SSH authentication even if in the way above.\n\n## How do `gosshauth` work for this?\n\n1. Check `$SSH_AUTH_SOCK`.\n2. `gosshauth` checks the existence.\n  - If exists, that's all, done.\n3. `gosshauth` globs all socket-like files for `/tmp/**/Listeners` and\n   `/tmp/ssh*/agent.*`.\n4. The candidate that has the latest timestamp is the goal, maybe.  `gosshauth`\n   rewrite the `~/.ssh/auth_sock` symlink to target the goal, and set\n   `$SSH_AUTH_SOCK` to use it.\n\n## Author\n\nJINNOUCHI Yasushi \u0026lt;me@delphinus.dev\u0026gt;\n\n## License\n\nThe MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelphinus%2Fgosshauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelphinus%2Fgosshauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelphinus%2Fgosshauth/lists"}