billchurch / webssh2

Web SSH Client using ssh2, socket.io, xterm.js, and express. webssh webssh2
MIT License
2.31k stars 532 forks source link

Can we integrate this with Vuejs #366

Open umardraz opened 1 month ago

umardraz commented 1 month ago

Hi Bill

Is it possible that we can integrate this in Vuejs Project?

billchurch commented 1 month ago

The app/client can be modified to fit any framework. See (Building)[https://github.com/billchurch/webssh2/blob/main/BUILDING.md] for more information.

However, I'm working on a project to split the client out of this repo, simplifying the process and making it easier to support different frameworks or do other custom modifications.

I hope to have something usable in the next couple of weeks. Some other priorities have kept me from completing some testing.

umardraz commented 1 month ago

Thanks, I will wait :)

billchurch commented 2 weeks ago

Ok. I don't have the "current" version refactored, but I did "refactor" and older branch. It's actually a total re-write but I had to target an old version of node for a specific use case.

The front end is:

The back end is currently in the bigip-server branch

I created a tag on dockerhub with this new version. It doesn't exactly solve your problem right now but I was hoping maybe you'd take a look at it and see what you think.

docker run -it --rm --name webssh2 -p 2222:2222 -e DEBUG="webssh2*" billchurch/webssh2:bigip-server

Documentation is kind of all over the place, and probably incomplete but you can look at the READMEs of the two repos:

The idea here is we can fork off webssh2_client for different frameworks and point them to the server instance...

Does that make sense? Let me know what you think.

umardraz commented 2 weeks ago

Well I had integrated your old web2ssh into my vue app. In my app I am simply open the iframe and using token instead of any html form for username, hostname or password. The Vue app on the fly get the token from python api.

http://localhost:2222/ssh/host?token=${newToken}

then in web2ssh/server/app.js, I had modified the following to use that token


//app.get('/ssh/host/:host?', (req, res) => {
app.get('/ssh/host', (req, res) => {

  const token = req.query.token;

  if (!token) {
    return res.status(400).send('Token is required');
  }
  try {
    const decoded = jwt.verify(token, 'token_secret');

      req.session.username = decoded.user,
      req.session.userpassword = decoded.password,
      req.session.privatekey = decoded.privatekey,

      res.sendFile(path.join(path.join(publicPath, 'client.htm')));

      // capture, assign, and validate variables
      req.session.ssh = {
        host: decoded.host,
        port: decoded.port,
        localAddress: '',
        localPort: '',
        header: {
          name: req.query.header || config.header.text,
          background: req.query.headerBackground || config.header.background,
        },