【问题标题】:connecting to a remote lisp without SSH不使用 SSH 连接到远程 lisp
【发布时间】:2016-06-04 20:49:30
【问题描述】:

我正在尝试连接到远程 lisp,它在我笔记本电脑的虚拟机上运行。在slime manual,我找到了这一行

有一种方法可以在没有 ssh 隧道的情况下进行连接,但它的副作用是让整个世界都可以访问您的 lisp 图像,所以我们不打算讨论它

这似乎有点过时了。我想在虚拟机上运行 lisp 将不允许任何其他人访问 lisp。

我的问题是,如何在没有 SSH 的情况下连接到远程 lisp?

[编辑]

我看到了here的问题,但是当我转发端口时,slime无法连接到swank并给我以下错误

Lisp connection closed unexpectedly: connection broken by remote peer

【问题讨论】:

标签: ssh lisp common-lisp slime


【解决方案1】:

您可以在虚拟机中使用 quicklisp 和 swank,然后在 this tutorial 或用于虚拟化环境的端口之后转发您打开 lisp 的端口。

在虚拟机上的 lisp 中:

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
?

然后使用 slime-connect 连接到您的虚拟机 ip 和您为 swank-server 选择的端口。

在其他情况下,ssh 也很容易。如果你想使用 ssh 连接到一台远程机器上的一个端口,简单的方法是使用 -L 选项,像这样

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

然后你使用 slime-connect 并连接到 localhost 和 local_port

这是一个使用 vagrant 的设置,只连接到机器的 ssh 来启动 swank,但你可以自动化它。

1) Vagrantfile:有转发端口和ip,还有roswell设置,你可以直接安装sbcl,这不重要但是用roswell很容易在一分钟内启动并运行lisp,这里重要的是正在运行 quicklisp。

# -*- 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 进入机器

3) ros run -Q #安装完sbcl后可以在REPL中使用quicklisp

4) 准备 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) 然后去你的emacs环境:

粘液连接

主机 192.168.33.24 4005端口

6)可能版本不同,接受它并继续

终于可以使用了

我相信这个技巧对你有用,最重要的是 swank::loopback-interface

【讨论】:

  • 但我试图避免使用 ssh
  • 第一部分,是避免ssh,你唯一要做的就是在你的slime-connect中选择你在swank-server中输入的虚拟机ip和端口,然后你就可以转发跨度>
  • @saq7 为什么要避免使用 ssh?
  • @sigjuice 因为每次都会少一个步骤
  • @anquegi 我尝试转发端口,但我收到一个非常无意义的错误Lisp connection closed unexpectedly: connection broken by remote peer
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-11
  • 1970-01-01
  • 2021-06-06
  • 1970-01-01
  • 2020-10-31
  • 2019-02-23
  • 2021-01-10
相关资源
最近更新 更多