{"id":13710290,"url":"https://github.com/desops/sshpool","last_synced_at":"2025-05-06T18:34:54.495Z","repository":{"id":57558403,"uuid":"322458806","full_name":"desops/sshpool","owner":"desops","description":"Connection pool for x/crypto/ssh connections","archived":false,"fork":false,"pushed_at":"2024-06-28T09:06:53.000Z","size":29,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-13T20:40:37.854Z","etag":null,"topics":["go","golang"],"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/desops.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-18T01:44:18.000Z","updated_at":"2024-06-28T09:06:49.000Z","dependencies_parsed_at":"2024-11-13T20:33:43.360Z","dependency_job_id":"3a15c6ed-b474-471d-a52e-8d4003f6364b","html_url":"https://github.com/desops/sshpool","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desops%2Fsshpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desops%2Fsshpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desops%2Fsshpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desops%2Fsshpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/desops","download_url":"https://codeload.github.com/desops/sshpool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252745034,"owners_count":21797723,"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":["go","golang"],"created_at":"2024-08-02T23:00:54.080Z","updated_at":"2025-05-06T18:34:54.162Z","avatar_url":"https://github.com/desops.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# sshpool\nConnection pool for x/crypto/ssh connections\n\nAPI docs: https://pkg.go.dev/github.com/desops/sshpool\n\nThis is a connection pooler for golang.org/x/crypto/ssh. It's good for making hundreds (or thousands) of SSH connections to do a lot of things on a lot of hosts.\n\nThe pool itself has no configuration apart from a ClientConfig:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\n\t\"github.com/desops/sshpool\"\n\t\"golang.org/x/crypto/ssh\"\n)\n\nfunc main() {\n\tif err := run(); err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(1)\n\t}\n}\n\nfunc run() error {\n\tbuf, err := ioutil.ReadFile(\"./keys/my_private_ssh_key\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkey, err := ssh.ParsePrivateKey(buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconfig := \u0026ssh.ClientConfig{\n\t\tUser: \"myuser\",\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.PublicKeys(key),\n\t\t},\n\t}\n\n\tpool := sshpool.New(config, nil)\n\n\tfor i := 0; i \u003c 100; i++ {\n\t\tgo func() {\n\t\t\terr := func() error {\n\t\t\t\tsession, err := pool.Get(\"myhost\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdefer session.Put() // important: this returns it to the pool\n\n\t\t\t\tsession.Stdout = os.Stdout\n\t\t\t\tsession.Stderr = os.Stderr\n\n\t\t\t\tif err := session.Run(\"sleep 10\"); err != nil {\n\t\t\t\t\tee, ok := err.(*ssh.ExitError)\n\t\t\t\t\tif ok {\n\t\t\t\t\t\treturn fmt.Errorf(\"remote command exit status %d\", ee.ExitStatus())\n\t\t\t\t\t}\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t\t}\n\t\t}()\n\t}\n\n\treturn nil\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesops%2Fsshpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesops%2Fsshpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesops%2Fsshpool/lists"}