GithubHelp home page GithubHelp logo

ssh-tunnels's Introduction

SSH tunnels

This package lets you run and kill SSH tunnels. To use it:

  • Set the variable ssh-tunnels-configurations, e.g.:
(setq ssh-tunnels-configurations
      '((:name "my local tunnel"
         :local-port 1234
         :remote-port 3306
         :login "me@host")
        (:name "my remote tunnel"
         :type "-R"
         :local-port 1234
         :remote-port 3306
         :login "me@host")
        (:name "my local socket tunnel"
         :type "-L"
         :local-socket "/tmp/socket"
         :remote-socket "/tmp/socket"
         :login "me@host")))
  • Type M-x ssh-tunnels RET

  • You should see the list of tunnels; running tunnels will have 'R' in their state column

  • To run the tunnel at the current line, type r

  • To kill a running tunnel, type k

  • You may want to temporarily change a tunnel's local port. To do that you may provide a prefix argument to the run command, for example by typing C-u 1235 r

Helm, Ido, Ivy

The package comes with a Helm frontend (M-x helm-ssh-tunnels) as well as completing-read frontends, which can be used with Ido or Ivy (M-x ssh-tunnels-run-tunnel and M-x ssh-tunnels-kill-tunnel).

Auto-ssh-tunnels-mode

This package also includes a global minor-mode that automatically starts SSH tunnels when Emacs's built-in open-network-stream function is used. Before a connection is made to a host and port that correspond to a tunnel's host and local port, this mode will make sure that the tunnel is running.

Use M-x auto-ssh-tunnels-mode to enable this global minor-mode.

License

MIT

ssh-tunnels's People

Contributors

death avatar evilham avatar gmlarumbe avatar miciah avatar montag451 avatar purcell avatar texaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ssh-tunnels's Issues

Allow for other tunnel types

I think this is related to #4 #3 albeit, I treated it more generically and actually did the thing:

  • Added a type property to tunnels, that defaults to -L and accepts -D or -R
  • If -D, RPort is optional and any setup value is ignored
  • Its value is listed on ssh-tunnels table

If there is a chance of merging this and publishing to elpa, please reply and I'll add the documentation strings and create a Merge Request.

A static port forwarding should NOT be a mandatory option

Hi,

I checked the source code, and found that -L is a mandatory option, which forces the user to define a static port forwarding. If I don't define a (:local-port :host :remote-port), then the ssh tunnel can't be setup. But what if I don't want a static port forwarding??? I have configured everything for a host in the ~/.ssh/config, maybe a dynamic port forwarding, and maybe a static one. Then in the SSH tunnels buffer, I just want to setup this already configured tunnel. So -L should NOT be a mandatory option. If the user defines that, then it can overwrite the behavior defined in ~/.ssh/config. otherwise just let .ssh/config do the rest thing. Could you please fix that? Thanks.

Emacs hangs after run an ssh tunnel

Hi,

Everytime after I type "r" to run an ssh tunnel in the SSH tunnels buffer, emacs hangs. I can find in external terminals that the ssh tunnel has been established successfully. I have to type "C-g" to wake emacs. Then I type "g" to refresh the ssh tunnel status, and I can get the "running" state. Everything works fine after that. Does it happen to anyone else? My emacs version is 24.3. Thanks.

Starting a tunnel hangs on message "Tunneling..."

Hi,

I am experiencing a regression: Starting a tunnel doesn't work for me anymore after I updated.

I in the minibuffer I see the message "Tunneling..." and then emacs hangs.
Interrupting and seeing the stacktrace showed me that emacs is in the function call-process within ssh-tunnels--command.

I did a git bisect and found this to be the problematic commit:
d3a7402

I am running Arch Linux.

16:28 $ uname -r
5.18.3-arch1-1
✔ ~ 
16:28 $ emacs --version
GNU Emacs 28.1
Copyright (C) 2022 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
✔ ~ 
16:28 $ ssh -V
OpenSSH_9.0p1, OpenSSL 1.1.1o  3 May 2022

Configuration does not accept symbols

The configuration variable ssh-tunnels-configurations does not accept symbols. This can be useful to parameterize whenever the user have tons of tunnels to configure.

For instance:

(use-package ssh-tunnels :ensure t
  :config
  (setq ahost "localhost" alogin "mytunnelserver")
  (setq ssh-tunnels-configurations
        '((:name "sometunnel" :local-port  8080 :remote-port  8080 :host ahost :login alogin))))

This configuration turns out on the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp alogin)
  call-process("ssh" nil t nil "-S" "sometunnel" "-O" "check" alogin)
  apply(call-process "ssh" nil t nil "-S" "sometunnel" ("-O" "check" alogin))

In case it is a feature that fits the package style and philosophy, it can be implemented checking whether the parameter (:login in this case) is a string within ssh-tunnels--command function. Other wise eval it.

  (defun ssh-tunnels--command (tunnel command)
    (let* ((name (ssh-tunnels--property tunnel :name))
         (tunnel-type (ssh-tunnels--property tunnel :type))
         (login (ssh-tunnels--property tunnel :login))
         (args
...

I can spend few hours on it if it may be an interesting feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.