Comments (24)
If you don't want to use wsProxy/node you can make the following modifications to the code as suggested in #4
This would enable you to use websocket proxies that operate via binary blobs ( such as websockify ). You may have issues multiplexing your connection to multiple SSH servers though unless your chosen websocket proxy also supports target servers in the URI.
e.g.
ws://${websocket_proxy}:${port}/${SSH_server}:${SSH_port}
These changes would be done in index.html or wrapper.html
// Opens the websocket!
ws = new WebSocket(wsproxyURL);
ws.binaryType = "arraybuffer";
// Send all recieved messages to SSHyClient.Transport.handle()
ws.onmessage = function(e) {
// ArrayBuffer to String
var enc = new TextDecoder("utf-8");
var clearMessage = enc.decode(e.data);
console.log(clearMessage);
transport.parceler.handle(clearMessage);
};
ws.sendB64 = function(e){
var enc = new TextEncoder();
this.send(enc.encode(e)); // String to ArrayBuffer conversion
console.log("sendB64", e);
transport.parceler.transmitData += e.length;
transport.settings.setNetTraffic(transport.parceler.transmitData, false);
};
from sshy.
Thanks for a quick reply.. So I just need to add this or also remove something?
from sshy.
The idea is just to connect to localhost:22
from sshy.
Would be replacing websocket definition & the onmessage() / sendB64()
functions which are around here:
https://github.com/stuicey/SSHy/blob/master/index.html#L221
https://github.com/stuicey/SSHy/blob/master/index.html#L232
https://github.com/stuicey/SSHy/blob/master/index.html#L258
from sshy.
Uncaught TypeError: Cannot set property 'onopen' of undefined
at startSSHy (wrapper.html:226)
at HTMLInputElement.onclick (wrapper.html:491)
from sshy.
If you're using the wrapper you'll need to modify this in SSHyClient.js and rebuild the min files (instructions in readme).
from sshy.
i am actually using index.html, but I copied a modified code as per your instructions to wrapper.html... It's still throwing errors
from sshy.
What browser are you using? and can you check what websocket proxy URL is being passed to the function? console.log(wsproxyURL)
just before ws = new WebSocket(wsproxyURL);
from sshy.
I am using the latest Chrome.. Even when adding that I don't see anything else in the console but this:
Uncaught TypeError: Cannot set property 'onopen' of undefined
at startSSHy (wrapper.html:226)
at HTMLInputElement.onclick (wrapper.html:492)
from sshy.
That doesn't sound right, if you're not getting any logs out for a wsproxyURL
it suggests its not set which would be why the websocket connection can't open.
Do you have your console sidebar configured to only show errors?
from sshy.
No, it's showing everything.. It's not showing anything, because it's within function startSSHy(), which is not starting
from sshy.
The stack trace indicates that the startSSHy
function does start and crashes when trying to set ws.onopen
. If you've replaced the code that was there with the modified version provided at the top of this chain then this shouldn't happen.
Do you want to attach the file and I'll have a look?
from sshy.
Sure..
https://jsfiddle.net/3umdx2nh/
from sshy.
You've added that code block in after ws.onopen
so it will be erroring as it hasn't set ws
to anything at that stage.
from sshy.
Thanks, I moved it up at this point.. But now I get this error:
wrapper.html:238 WebSocket connection to 'ws://localhost:5999/localhost:22' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
from sshy.
from sshy.
https://jsfiddle.net/yo43fc7w/
from sshy.
You'll need to change how the wsproxy URL is generated and set the new proxy URL appropriately.
Currently it expects the proxy to be on either port 5999(ws://) or 6001(wss://). Additionally it appends the IP/port of your target to the uri. This likely won't work with other websocket proxies so you will need to configure this yourself based on whatever proxy you choose.
from sshy.
Well y'all are a lot closer to SSHing online than I am. My page keeps trying to connect to:
WebSocket connection to 'wss://wss//ebdev:6001/:6001/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
I'm not even sure how that happened...
Edit:
I do believe that the "ebdev:6001" is referencing my user account, webdev
from sshy.
You probably set the full webproxy url as wsProxyURL
at the top. You'll need to modify or remove the buildWSProxyURL()
function.
https://github.com/stuicey/SSHy/blob/master/index.html#L74
This function constructs the URL in the form:
$protocol://$websocketProxy:$websocketURL/$SSHServer:$SshPort
from sshy.
WebSocket connection to 'wss://ebdev:6001/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
Progress... I downloaded the latest commit, and I haven't touched anything either. Not quite sure if something else is wrong, or if I missed a step. Sorry if I'm being a difficult.
from sshy.
Debugging through Chrome, and it seems to be complaining about this...
ws = new WebSocket(wsproxyURL); //PROBLEM ACCORDING TO CHROME
ws.binaryType = "arraybuffer";
// Send all recieved messages to SSHyClient.Transport.handle()
ws.onmessage = function(e) {
// ArrayBuffer to String
var enc = new TextDecoder("utf-8");
var clearMessage = enc.decode(e.data);
console.log(clearMessage);
transport.parceler.handle(clearMessage);
};
ws.sendB64 = function(e){
var enc = new TextEncoder();
this.send(enc.encode(e)); // String to ArrayBuffer conversion
console.log("sendB64", e);
from sshy.
The error suggests it can't resolve the domain name ebdev
. Have you configured a custom DNS or setup the IP for this in your hosts file?
from sshy.
Hosts file? The only time I've touched that is to just setup my main domain. Unless if there is a hosts file in this project that I am unaware of, I have not.
from sshy.
Related Issues (20)
- Question and Possible bug. HOT 4
- Question: SSHy as angular/vue component?
- Keeps loading without connecting - wsproxy problem HOT 1
- can we have a ssh client that needs to creds
- Is there any way to include user name in wrapper.html? HOT 2
- Stuck on connecting... HOT 4
- Question: Predefined commands? HOT 2
- Support for binary websockets HOT 3
- Better error handling
- Error connecting to Debian / OpenSSH 7.4 HOT 6
- DOMException: Failed to execute 'atob' on 'Window' HOT 1
- Unable to closure-compile or connect HOT 1
- Safari support
- Really dumb question
- Stopped working with latest browsers HOT 28
- Can't send return key in latest Chrome 90.0.4430.93 HOT 1
- Failed to execute 'atob' on 'Window'
- Latest Chrome Update broke user return HOT 2
- WebSocket connection failed: Error in connection establishment: code 1005 HOT 2
- Invalid Signature Using Public Key Auth
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sshy.