4

I am trying to connect to a remote lisp, which is running on a virtual machine on my laptop. In the slime manual, I found this line

there is a way to connect without an ssh tunnel, but it has the side-effect of giving the entire world access to your lisp image, so we’re not going to talk about it

This seems a bit dated. I would imagine that running the lisp on a virtual machine will not allow any one else to access the lisp.

My question is, how do I connect to a remote lisp without SSH?

[EDIT]

I have seen the question here, but when I forward the port, slime is not able to connect to swank and gives me the following error

Lisp connection closed unexpectedly: connection broken by remote peer
Community
  • 1
  • 1
saq7
  • 1,528
  • 1
  • 12
  • 25
  • 1
    Possible duplicate of [How can I define the address that swank server should listen to?](http://stackoverflow.com/questions/5930230/how-can-i-define-the-address-that-swank-server-should-listen-to) – hcs Jun 04 '16 at 21:00

1 Answers1

2

You could use quicklisp and swank in the virtual machine then forward the port you open the lisp following this tutorial or the one for the environment you use for virtualization.

In your lisp on the virtual machine:

Welcome to Clozure Common Lisp Version 1.11-r16635  (DarwinX8664)!

CCL is developed and maintained by Clozure Associates. For more information
about CCL visit http://ccl.clozure.com.  To enquire about Clozure's Common Lisp
consulting services e-mail info@clozure.com or visit http://www.clozure.com.

? (ql:quickload :swank)
To load "swank":
  Load 1 ASDF system:
    swank
; Loading "swank"
.....
(:SWANK)
? (swank:create-server)
;; Swank started at port: 4005.
4005
?

then use slime-connect to connect to your virtual machine ip and the port you choose for the swank-server.

In other case for ssh is also easy.if you want to connect to one port in one remote machine using ssh the easy way is using the -L option like this

ssh user@ip -p22 -L local_port:localhost:remote_port

then you use slime-connect and connect to localhost and the local_port

This is a setup using vagrant, only connect to ssh to the machine to startup swank, but you can automatize it.

1) Vagrantfile: with the forwarding port and the ip, and the roswell setup, you can install directly sbcl, it is not important but with roswell is easy to get lisp up and running in a minute, the important thing here is having quicklisp running.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"

  config.vm.network "forwarded_port", guest: 4005, host: 4005

  config.vm.network "private_network", ip: "192.168.33.24"

  config.vm.provider "virtualbox" do |vb|
      vb.name = "lisp_host"
      vb.gui = false
      vb.memory = "1024"
    end

  config.vm.provision "shell",
  inline: "apt-get update
  if which apt-get > /dev/null; then sudo apt-get -y install git build-essential automake libcurl4-openssl-dev;fi
  git clone -b release https://github.com/roswell/roswell.git
  cd roswell
  sh bootstrap
  ./configure
  make
  sudo make install
  sudo ros setup"
  # SHELL 

end

2) vagrant up amd vagrant ssh to go inside the machine

3) ros run -Q #after installing the sbcl you can use quicklisp in the REPL

4) Preparing swank

    2016-06-06 12:32:55 ☆ |ruby-2.2.3@laguna| Antonios-MBP in ~/learn/lisp/stackoverflow/vagrant-env
    ○ → vagrant ssh
    Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-79-generic x86_64)

     * Documentation:  https://help.ubuntu.com/

      System information as of Mon Jun  6 10:26:56 UTC 2016

      System load:  0.41              Processes:           84
      Usage of /:   4.7% of 39.34GB   Users logged in:     0
      Memory usage: 12%               IP address for eth0: 10.0.2.15
      Swap usage:   0%                IP address for eth1: 192.168.33.24

      Graph this data and manage this system at:
        https://landscape.canonical.com/

      Get cloud support with Ubuntu Advantage Cloud Guest:
        http://www.ubuntu.com/business/services/cloud


    Last login: Mon Jun  6 10:26:56 2016 from 10.0.2.2
    vagrant@vagrant-ubuntu-trusty-64:~$ ros run -Q
    WARNING: Setting locale failed.
      Check the following variables for correct values:
      LC_CTYPE=UTF-8
      LANG=en_US.UTF-8
    * (ql:quickload :swank)
    To load "swank":
      Load 1 ASDF system:
        swank
    ; Loading "swank"
    .
    (:SWANK)
    * (setf swank::*loopback-interface* "192.168.33.24") ;Important to listen throught the internet IP

    "192.168.33.24"
    * (swank:create-server)
    ;; Swank started at port: 4005.

4005

5) Then go to you emacs environment:

slime-connect

host 192.168.33.24 port 4005

6) maybe the version is different accept it and go on

Finally you can use it

I believe that this tricks could work for you the most important is the swank::loopback-interface

anquegi
  • 11,125
  • 4
  • 51
  • 67
  • but i am trying to avoid using ssh – saq7 Jun 05 '16 at 01:41
  • 1
    The first part, is avoifing ssh, the only thing you have to do is in your slime-connect choose the virtual machine ip and the port you put in swank-server, and you previosly forward – anquegi Jun 05 '16 at 06:55
  • 1
    @saq7 Why do you want to avoid ssh? – sigjuice Jun 05 '16 at 08:04
  • @sigjuice because there would be one less step to do everytime – saq7 Jun 05 '16 at 16:29
  • @anquegi I tried forwarding the ports, but I get a very uninformative error `Lisp connection closed unexpectedly: connection broken by remote peer` – saq7 Jun 05 '16 at 16:30
  • @saq7 I will try to add a sample using vagrant and slime – anquegi Jun 06 '16 at 08:35
  • @saq7 I updated it with a complete sample, and also changing the binding for one swank variable, take a loot at this. I hope this should work – anquegi Jun 06 '16 at 10:46
  • @anquegi thanks for the detailed edit! Unfortunately, I am still getting the same message in Emacs `Lisp connection closed unexpectedly: connection broken by remote peer`. I get this as soon as I run the slime-connect command. No other messages, not anything. I also have a dedicated linux box, and this worked on that, without needing to change the loopback-interface. It just doesn't work in VM... – saq7 Jun 06 '16 at 14:58
  • @anquegi I haven't tried telnet. But I did try forwarding the port on the VM using the -L flag to SSH. same error. I'll try telnet – saq7 Jun 06 '16 at 15:55