{"id":29108762,"url":"https://github.com/brunotm/sshmgr","last_synced_at":"2025-06-29T06:37:38.202Z","repository":{"id":57499226,"uuid":"88502099","full_name":"brunotm/sshmgr","owner":"brunotm","description":"Go goroutine safe manager for SSH clients sharing between ssh/sftp sessions","archived":false,"fork":false,"pushed_at":"2018-09-15T21:29:48.000Z","size":233,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-08-11T22:11:40.175Z","etag":null,"topics":["go","golang","goroutine-safe","sftp","ssh"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brunotm.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":"2017-04-17T11:33:07.000Z","updated_at":"2018-09-15T21:29:50.000Z","dependencies_parsed_at":"2022-08-28T15:10:55.017Z","dependency_job_id":null,"html_url":"https://github.com/brunotm/sshmgr","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/brunotm/sshmgr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunotm%2Fsshmgr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunotm%2Fsshmgr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunotm%2Fsshmgr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunotm%2Fsshmgr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunotm","download_url":"https://codeload.github.com/brunotm/sshmgr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunotm%2Fsshmgr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262548873,"owners_count":23327430,"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","goroutine-safe","sftp","ssh"],"created_at":"2025-06-29T06:37:36.776Z","updated_at":"2025-06-29T06:37:38.192Z","avatar_url":"https://github.com/brunotm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go sshmgr\n\n[![Build Status](https://travis-ci.org/brunotm/sshmgr.svg?branch=master)](https://travis-ci.org/brunotm/sshmgr) [![Go Report Card](https://goreportcard.com/badge/github.com/brunotm/sshmgr)](https://goreportcard.com/report/github.com/brunotm/sshmgr)\n====\n\n### A goroutine safe manager for SSH and SFTP client sharing.\n\nIt makes possible to share and reutilize existing clients for the same host `made with the same user,port and credentials` between multiple goroutines.\u003c/br\u003e\n\nClients are reference counted, and automatically closed/removed from the manager when they have no references and the client TTL is exceeded.\n\n-----------------------------------------------------------\n## Usage:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"time\"\n\n\t\"github.com/brunotm/sshmgr\"\n)\n\nfunc main() {\n\n\t// Creates a manager with a client ttl of 10 seconds and\n\t// a GC interval of 5 seconds\n\tmanager := sshmgr.New(time.Second*10, time.Second*5)\n\tdefer manager.Close()\n\n\tkey, err := ioutil.ReadFile(\"/path/to/key\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tconfig := sshmgr.ClientConfig{}\n\tconfig.NetAddr = \"hosta\"\n\tconfig.Port = \"22\"\n\tconfig.User = \"root\"\n\tconfig.Password = \"\"\n\tconfig.Key = key\n\tconfig.IgnoreHostKey = true\n\tconfig.ConnDeadline = time.Minute\n\tconfig.DialTimeout = time.Second * 5\n\n\tclient, err := manager.SSHClient(config)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// Must close the client when done.\n\tdefer client.Close()\n\n\tdata, err := client.CombinedOutput(\"uptime\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"%s: %s\", config.NetAddr, string(data))\n}\n\n```\n\nWritten by Bruno Moura \u003cbrunotm@gmail.com\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunotm%2Fsshmgr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunotm%2Fsshmgr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunotm%2Fsshmgr/lists"}