{"id":13577009,"url":"https://github.com/tsurubee/sshr","last_synced_at":"2026-03-13T04:38:29.068Z","repository":{"id":57504167,"uuid":"143428999","full_name":"tsurubee/sshr","owner":"tsurubee","description":"Proxy server for routing SSH connections","archived":false,"fork":false,"pushed_at":"2024-03-05T07:26:10.000Z","size":1330,"stargazers_count":205,"open_issues_count":1,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T09:34:23.762Z","etag":null,"topics":["golang","proxy","ssh","ssh-proxy"],"latest_commit_sha":null,"homepage":null,"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/tsurubee.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":"2018-08-03T13:11:17.000Z","updated_at":"2025-02-22T01:07:31.000Z","dependencies_parsed_at":"2024-03-17T06:59:43.911Z","dependency_job_id":null,"html_url":"https://github.com/tsurubee/sshr","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/tsurubee/sshr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsurubee%2Fsshr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsurubee%2Fsshr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsurubee%2Fsshr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsurubee%2Fsshr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsurubee","download_url":"https://codeload.github.com/tsurubee/sshr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsurubee%2Fsshr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30458003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T03:55:51.346Z","status":"ssl_error","status_checked_at":"2026-03-13T03:55:33.055Z","response_time":60,"last_error":"SSL_read: 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":["golang","proxy","ssh","ssh-proxy"],"created_at":"2024-08-01T15:01:16.862Z","updated_at":"2026-03-13T04:38:29.060Z","avatar_url":"https://github.com/tsurubee.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# sshr\n[![Build Status](https://travis-ci.org/tsurubee/sshr.svg?branch=master)](https://travis-ci.org/tsurubee/sshr)  \n\nsshr is an SSH proxy server whose client is not aware of the connection destination.  \nA developer using sshr can freely incorporate own hooks that dynamically determines the destination host from the SSH username.  Therefore, for example, when the server administrator wants to centrally manage the linkage information between the SSH user and the server to be used in the DB, you can refer to the destination host from the DB with the hook that can be pluggable in sshr.\n\n※ The main logic of sshr is implemented in [proxy.go](https://github.com/tsurubee/sshr.crypto/blob/master/ssh/proxy.go) of the [tsurubee/sshr.crypto](https://github.com/tsurubee/sshr.crypto) repository forked from [golang/crypto](https://github.com/golang/crypto).  \n\n\u003cimg src=\"./docs/images/conceptual_scheme.png\" alt=\"conceptual_scheme\" width=\"800\"\u003e\n\n## Usage\n### Installation\n```\n$ go get github.com/tsurubee/sshr\n```\n\n### Example\n```go\nfunc main() {\n\tconfFile := \"./example.toml\"\n\n\tsshServer, err := sshr.NewSSHServer(confFile)\n\tif err != nil {\n\t\tfmt.Errorf(\"Error: %s\", err)\n\t}\n\n\tsshServer.ProxyConfig.FindUpstreamHook = FindUpstreamByUsername\n\tif err := sshServer.ListenAndServe(); err != nil {\n\t\tfmt.Errorf(\"Error: %s\", err)\n\t}\n}\n\nfunc FindUpstreamByUsername(username string) (string, error) {\n\tif username == \"tsurubee\" {\n\t\treturn \"host-tsurubee\", nil\n\t} else {\n\t\treturn \"\", errors.New(username + \"'s host is not found!\")\n\t}\n}\n\n```\nFindUpstreamHook is a hook that can be pluggable, which allows you to write your own logic to dynamically determine the destination host from the SSH username.\n\n### Quick start  \nAfter Installation, test environment can be easily set up by using `docker-compose`.  \n```\n$ docker-compose up\n・・・\nssh-proxy_1      | ==\u003e Installing Dependencies\nssh-proxy_1      | go get -u github.com/golang/dep/...\nhost-tsurubee_1  | Starting crond: [  OK  ]\nhost-hoge_1      | Starting crond: [  OK  ]\nssh-proxy_1      | dep ensure\nssh-proxy_1      | go run main.go\nssh-proxy_1      | time=\"2018-09-22T09:23:00Z\" level=info msg=\"Start Listening on [::]:2222\"\n```\nThe sshr server is listening on port 2222 of the localhost, and we can login to the server as `tsurubee` or `hoge` user like below.  (Password is `testpass`)\n```\n$ ssh tsurubee@127.0.0.1 -p 2222\ntsurubee@127.0.0.1's password:\n[tsurubee@host-tsurubee ~]$\n```\nWe can also login with the public key authentication.  (At the first time, we need to change permissions by `chmod`)\n```\n$ chmod 600 ./misc/testdata/client_keys/id_rsa\n$ ssh -i ./misc/testdata/client_keys/id_rsa tsurubee@127.0.0.1 -p 2222\nLast login: Sat Sep 22 09:31:18 2018 from sshr_ssh-proxy_1.sshr_defaul\n[tsurubee@host-tsurubee ~]$ \n```\n\n### Pluggable Hooks\nIn order to be able to flexibly change the behavior of the proxy server, sshr can freely incorporate the following hooks.  \n\n#### FindUpstreamHook（Required）\nFindUpstreamHook is for specifying upstream host by SSH username.  \n```\nType: func(username string) (string, error)\n```\n\n#### FetchAuthorizedKeysHook（Optional）\nFetchAuthorizedKeysHook is for fetching authorized_keys to confirm registration of the client's public key.  \n```\nType: func(username string, host string) ([]byte, error)\n```\nIf not specified, `authorized_keys` is fetched from `/home/\u003cusername\u003e/.ssh/`.  \n\n#### FetchPrivateKeyHook（Optional）\nFetchPrivateKeyHook is for fetching the private key used when sshr performs publickey authentication as a client user to the upstream host.  \n\n```\nType: func(username string) ([]byte, error)\n```\nIf not specified, privatekey whose file path is `/home/\u003cusername\u003e/.ssh/id_rsa` is used.  \n\n## Publications\n\n1. H. Tsuruta and R. Matsumoto, “[sshr: An SSH Proxy Server Responsive to System Changes without Forcing Clients to Change](https://ieeexplore.ieee.org/document/9202744)”, in *The 15th IEEE International Workshop on Security, Trust \u0026 Privacy for Software Applications (STPSA 2020)*, July 2020.\n\n## License\n\n[MIT](https://github.com/tsurubee/sshr/blob/master/LICENSE)\n\n## Author\n\n[tsurubee](https://github.com/tsurubee)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsurubee%2Fsshr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsurubee%2Fsshr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsurubee%2Fsshr/lists"}