sshr icon indicating copy to clipboard operation
sshr copied to clipboard

ssh proxy route connection by ssh options SendEnv ?

Open kelify opened this issue 1 year ago • 3 comments

i want to use that porject as a ssh router , my mutli backend or upstream linux server has a same user account. so i am going to use client command like that "ssh user@proxy_address -p 2222 -o SendEnv=upstream_addr -o SendEnv=upsream_port " to connect the proxy server ,and than the server will route connection by env . how to do that at this project?

kelify avatar Apr 19 '24 09:04 kelify

hi, here is how I would translate your situation with the use I make of this project:

ssh user_upstreamIdentifier@proxy_address -p 2222

with following impl:

func FindUpstreamByUsername(username string) (string, error) {
	parts := strings.Split(username, "_")
	if len(parts) == 2 {
		host := parts[1]
		if host == "upstream1" {
                      return "10.0.0.5" // or net.LookupHost(host)...
                }
	}
	return "", errors.New("access denied")
}

jonathanMelly avatar Apr 19 '24 10:04 jonathanMelly

hi, thranks for your answer, but my background is my upstreams server have a same account for login. in your example, that username actually pass to upstream server is difference. can you have some method to impl my purpose?

kelify avatar Apr 19 '24 10:04 kelify

hi, thranks for your answer, but my background is my upstreams server have a same account for login. in your example, that username actually pass to upstream server is difference. can you have some method to impl my purpose?

Ok from what I understand of your requirement and this project what you want is not possible as sshr is "just tunneling" the network traffic (incl. original username) to a host...

@tsurubee am I right ?

jonathanMelly avatar Apr 19 '24 11:04 jonathanMelly