stechstudio / laravel-ssh-tunnel

Easy creation & maintenance of an SSH Tunnel for Laravel/Lumen
MIT License
191 stars 49 forks source link

Could Not Create SSH Tunnel with command #29

Closed bachras closed 5 years ago

bachras commented 5 years ago

hi,

I have similar or same issue as mentioned in https://github.com/stechstudio/laravel-ssh-tunnel/issues/16 .

Error:

Could Not Create SSH Tunnel with command:
    /usr/bin/ssh -o StrictHostKeyChecking=no  -N -i /home/projectX/.ssh/id_rsa -L 13306:
remoteIP:3306 -p 22 xxx@srv.xxx.com
Check your configuration

  at /home/projectX/laravel/vendor/stechstudio/laravel-ssh-tunnel/src/Jobs/CreateTunnel.php:72
    68|             // Wait a bit until next iteration
    69|             usleep(config('tunneler.wait'));
    70|         }
    71| 
  > 72|         throw new \ErrorException(sprintf("Could Not Create SSH Tunnel with command:\n\t%s\nCheck your configuration.",
    73|             $this->sshCommand));
    74|     }
    75| 
    76| 

  Exception trace:

  1   STS\Tunneler\Jobs\CreateTunnel::handle()
      /home/projectX/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

In https://github.com/stechstudio/laravel-ssh-tunnel/issues/16#issuecomment-365608183 you have mentioned that it is permissions problem. I am running from same user who owns the Laravel project and folder there. I don't know where to look for problem now. Any help would be appreciated. Thanks

V13Axel commented 5 years ago

Does the SSH tunnel work when you run that command directly?

bachras commented 5 years ago

@V13Axel sorry forgot to mention that. Yes it is working if I run command manually.

vesper8 commented 5 years ago

I have the same issue. If I add dispatch(new \STS\Tunneler\Jobs\CreateTunnel()); prior to using the tunnel, I get the above error.. and it obviously never allows the script to go past that point. If however, I go back into the file where that command is and comment it out, and then run it again, then it actually works. So it looks like the tunnel does get created, even though the error is thrown every time

The same script works fine on my dev environment

It is failing on Ubuntu 18.04

If I run the command manually on the production server, then it also works fine without error

vesper8 commented 5 years ago

Please see my PR here https://github.com/stechstudio/laravel-ssh-tunnel/pull/32

I believe you've run into the same issue as I have which relates to the nc (netcat) command not working with the -z flag alone on newer versions

My PR adds the -vz command which fixes this issue. The other fixes in my PR are also probably needed to remove all errors

bubba-h57 commented 5 years ago

This is resolved by the latest release 2.0.0 hot of the press, thanks to @vesper8 .

debaser19 commented 3 years ago

hey all, i seem to also be having a similar issue here. running on ubuntu 20.04 lts.

Could Not Create SSH Tunnel with command:
        ssh   -N -i /var/www/api/*****.key -L 43306:remote_ip:3306 -p 22 user@domain.com
Check your configuration.

I've checked to make sure I have the latest version pulled, it seems that the tunnel actually does get created when running the command, as I can see it when running netstat -tulpen | grep 43306

tcp        0      0 127.0.0.1:43306         0.0.0.0:*               LISTEN      1001       23038      1351/ssh

Also seems to run fine when manually running the ssh command shown in the error.

Permissions seem to be fine. Any ideas?