{"id":32990359,"url":"https://github.com/cosiner/socker","last_synced_at":"2026-02-15T04:37:23.480Z","repository":{"id":57485356,"uuid":"66205848","full_name":"cosiner/socker","owner":"cosiner","description":"A Go library to simplify the use of SSH for devops","archived":false,"fork":false,"pushed_at":"2023-03-29T03:51:56.000Z","size":52,"stargazers_count":252,"open_issues_count":1,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-15T12:32:59.003Z","etag":null,"topics":["devops","golang","ssh"],"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/cosiner.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}},"created_at":"2016-08-21T15:27:57.000Z","updated_at":"2024-09-25T13:11:33.000Z","dependencies_parsed_at":"2024-04-12T23:00:49.740Z","dependency_job_id":null,"html_url":"https://github.com/cosiner/socker","commit_stats":null,"previous_names":["zhuah/socker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cosiner/socker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosiner%2Fsocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosiner%2Fsocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosiner%2Fsocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosiner%2Fsocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosiner","download_url":"https://codeload.github.com/cosiner/socker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosiner%2Fsocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29469711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T04:35:06.950Z","status":"ssl_error","status_checked_at":"2026-02-15T04:33:41.357Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["devops","golang","ssh"],"created_at":"2025-11-13T09:00:29.083Z","updated_at":"2026-02-15T04:37:23.474Z","avatar_url":"https://github.com/cosiner.png","language":"Go","readme":"# Socker\n\nSocker is a library for [Go](https://golang.org) to simplify the use of SSH, support keepalive and multiplexing.\nInspired by [Fabric](http://www.fabfile.org) for Python.\n\n# Documentation\nDocumentation can be found at [Godoc](https://godoc.org/github.com/cosiner/socker)\n\n# Example\n```Go\nvar sshConfig = (\u0026Auth{User: \"root\", Password: \"root\"}).MustSSHConfig()\n\nfunc TestGate(t *testing.T) {\n\tgate, err := Dial(\"10.0.1.1\", sshConfig)\n\tif err != nil {\n\t\tt.Error(\"dial agent failed:\", err)\n\t}\n\tdefer gate.Close()\n\n\ttestSSH(t, gate)\n}\n\nfunc TestSSH(t *testing.T) {\n\ttestSSH(t, nil)\n}\n\nfunc testSSH(t *testing.T, gate *SSH) {\n\tagent, err := Dial(\"192.168.1.1\", sshConfig, gate)\n\tif err != nil {\n\t\tt.Error(\"dial agent failed:\", err)\n\t}\n\tdefer agent.Close()\n\n\ttestAgent(t, agent)\n}\n\nfunc testAgent(t *testing.T, agent *SSH) {\n\tagent.Rcmd(\"ls -al ~/\")\n\tagent.Put(\"~/local\", \"~/remote\")\n\tagent.Get(\"~/remote\", \"~/local\")\n\n\tagent.RcmdBg(\"sleep 30\", \"sleep.out\", \"sleep.err\")\n\n\tt.Log(string(agent.Output()))\n\terr := agent.Error()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestMux(t *testing.T) {\n\tvar (\n\t\tnetFoo  = \"netFoo\"\n\t\tgateFoo = \"10.0.1.1\"\n\t\tauthFoo = \u0026Auth{User: \"foo\", Password: \"foo\"}\n\t\tnetBar  = \"netBar\"\n\t\tauthBar = \u0026Auth{User: \"bar\", Password: \"bar\"}\n\t\tgateBar = \"10.0.2.1\"\n\t)\n\n\tauth := MuxAuth{\n\t\tAuthMethods: map[string]*Auth{\n\t\t\tnetFoo: authFoo,\n\t\t\tnetBar: authBar,\n\t\t},\n\n\t\tDefaultAuth: netFoo,\n\t\tAgentGates: map[string]string{\n\t\t\t\"ipnet:192.168.1.0/24\": gateFoo + \":22\",\n\t\t\t\"ipnet:192.168.2.0/24\": gateBar + \":22\",\n\t\t},\n\t\tAgentAuths: map[string]string{\n\t\t\t\"plain:\" + gateFoo:     netFoo,\n\t\t\t\"ipnet:192.168.1.0/24\": netFoo,\n\t\t\t\"plain:\" + gateBar:     netBar,\n\t\t\t\"ipnet:192.168.2.0/24\": netBar,\n\t\t},\n\t\tKeepAliveSeconds: 30,\n\t}\n\n\tmux, err := NewMux(auth)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttype testCase struct {\n\t\tAddr  string\n\t\tGate  string\n\t\tAuth  *Auth\n\t\tError error\n\t}\n\tcases := []testCase{\n\t\t{Addr: gateFoo, Gate: \"\", Auth: authFoo},\n\t\t{Addr: \"192.168.1.1\", Gate: gateFoo, Auth: authFoo},\n\t\t{Addr: \"192.168.1.255\", Gate: gateFoo, Auth: authFoo},\n\n\t\t{Addr: gateBar, Gate: \"\", Auth: authBar},\n\t\t{Addr: \"192.168.2.1\", Gate: gateBar, Auth: authBar},\n\t\t{Addr: \"192.168.2.255\", Gate: gateBar, Auth: authBar},\n\n\t\t{Addr: \"192.168.3.1\", Gate: \"\", Auth: authFoo, Error: nil},\n\t}\n\n\tfor _, c := range cases {\n\t\tif got := mux.AgentGate(c.Addr); got != c.Gate {\n\t\t\tt.Errorf(\"gate match failed %s: expect %s, got %s\", c.Addr, c.Gate, got)\n\t\t}\n\t\tgot, gotError := mux.AgentAuth(c.Addr)\n\t\tif got != c.Auth {\n\t\t\tt.Errorf(\"auth match failed %s\", c.Addr)\n\t\t}\n\t\tif gotError != c.Error {\n\t\t\tt.Errorf(\"auth error match failed %s: expect %v, got %v\", c.Addr, c.Error, gotError)\n\t\t}\n\t}\n\tdefer mux.Close()\n\n\tvar wg sync.WaitGroup\n\tfor _, addr := range []string{\"192.168.1.2:22\", \"192.168.2.2:22\"} {\n\t\tagent, err := mux.Dial(addr)\n\t\tif err != nil {\n\t\t\tt.Error(\"dial agent failed:\", err)\n\t\t\tbreak\n\t\t}\n\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer agent.Close()\n\t\t\tdefer wg.Done()\n\n\t\t\ttestAgent(t, agent)\n\t\t}()\n\t}\n\n\twg.Wait()\n}\n```\n\n# LICENSE\nMIT.\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Alternatives to *SSH*"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosiner%2Fsocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosiner%2Fsocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosiner%2Fsocker/lists"}