Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting via a web client using a web proxy #202

Closed
AlexanderZhirov opened this issue Dec 11, 2022 · 5 comments
Closed

Connecting via a web client using a web proxy #202

AlexanderZhirov opened this issue Dec 11, 2022 · 5 comments

Comments

@AlexanderZhirov
Copy link

AlexanderZhirov commented Dec 11, 2022

I have a large number of embedded systems that use Dropbear as an SSH server. The task is to make them freely accessible using a web application. To do this, I have developed an internal site in which I want to implement an SSH client based on web sockets. For this purpose, I used a ready-made open source product SSHy. Since he was not active in development for a long time, I used a modified fork of this project. I used websockify as a proxy server.

The problem is that there is a hang during the connection process. As far as my knowledge allows me to understand all this, I mean that the problem is in the handshake process - at some stage of the packet exchange, some kind of failure occurs somewhere. I can't quite identify it, because I don't fully understand the whole concept of SSH.

изображение

Using tcpdump, I took a packet dump. It can be seen that the connection is happening, but the process freezes.

On the server side, you can also see that the connection is taking place and the Dropbear child process appears.

изображение

I tried to join the OpenSSH server using this client and the connection was successful. I mean that the exchange process happens somehow differently. And how exactly - I can't understand. I ask for guru's help.

pcap dropbear connection file

mkj added a commit to mkj/SSHy that referenced this issue Dec 12, 2022
Instead of assuming the first tcp read contains just the remote version
string, instead we search for the \r\n end, then pass the rest along
to packet processing.

An attempt at fixing mkj/dropbear#202

Not yet tested.
@mkj
Copy link
Owner

mkj commented Dec 12, 2022

I've made a try at fixing the SSHy version parsing, though couldn't get index.html to work with my websocksify (didn't even get to connecting) - you can see if it works or modify as required.

@AlexanderZhirov
Copy link
Author

@mkj For some reason, the utility does not quite correctly create a library for me. It will be necessary to try again.

изображение

I'll try again and write to you later. Thank you very much!

@AlexanderZhirov
Copy link
Author

AlexanderZhirov commented Dec 12, 2022

@mkj No, after all, the library was assembled correctly, without errors, but, for some reason, with 4 warnings.

/usr/lib/openjdk-8/bin/java -jar closure-compiler.jar --js_output_file=combinedJS.comb.js js/defines.js js/src/*.js js/*.js '!**.comb.js'
...
0 error(s), 4 warning(s)

At the same time, there were even more errors. I suspect that the error most likely occurs at the initialization stage.

изображение

изображение

I'm using a template wrapper.html. It uses the combinedJS.comb.js, so I build it through java

...
	<script type="text/javascript">
		var wsproxyURL = "ws://46.72.31.224:2222"
		setProxyEncoding("binary");
	</script>
...

I have websockify running on port 2222 in Docker. It redirects to port 22 on Dropbear.

You can check. You can not create a proxy for yourself, but use mine, which will knock on Dropbear. I keep it all on virtual machines, so access is open.

  • 46.72.31.224:22 - DropBear
  • 46.72.31.224:2222 - Websockify => Dropbear:22
user:     root
password: poOZp*ZTK-69Y

@mkj
Copy link
Owner

mkj commented Dec 22, 2022

Seems to be working now with SSHy changes discussed in mkj/SSHy@7ac3941

@mkj mkj closed this as completed Dec 22, 2022
@AlexanderZhirov
Copy link
Author

Thanks! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants