通过SSH隧道将Dispy与端口转发一起使用 [英] Using dispy with port forwarding via ssh tunnel

查看:128
本文介绍了通过SSH隧道将Dispy与端口转发一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在远程服务器上运行的dispynode.我正在尝试从计算机(客户端)打开SSH隧道,并将dispyJobCluster配置为使用此隧道.但这不起作用.我没有配置这个权利吗?这是我的操作方式:

I have dispynode running on a remote server. I'm trying to open an SSH tunnel from my computer (client) and configure dispyJobCluster to use this tunnel. But it's not working. Am I not configuring this right ? Here's how I'm doing this :

(ps.我对分布式和并行计算或网络技术不了解,我是一名土木工程师,因此,如果我有时不使用正确的技术用语,请原谅我 )

( p.s . i don't have a deep knowledge in distributed & parallel computing nor networking, I'm a civil engineer so please excuse me if I don't use the right technical words sometimes)

SSH隧道:

plink -v -ssh -L 61:localhost:21 user@myserver.net

这会将连接转发到端口61到运行 dispynode 的服务器上的localhost:21

This will forward connections to port 61 to localhost:21 on the server where dispynode is running

dispynode:

sudo dispynode.py -d --ext_ip_addr localhost -p 21 -i localhost

将侦听端口21并使用localhost进行传输,该主机将通过隧道将其引导回客户端

will listen on port 21 and transmit using localhost which leads it though the tunnel back to the client

使用此dispyClient JobCluster 代码:

with this dispyClient JobCluster code :

cluster = dispy.JobCluster( runCasterDispyWorker,
                            nodes=[('localhost',61)], \
                            ip_addr='localhost', \
                            ext_ip_addr='localhost', \
                            port = 61, \
                            node_port = 21, \
                            recover_file='recover.rec', \
                            )

启动 dispy.py 时,在打开SSH隧道的命令提示符中出现以下错误:

When I launch the dispy.py I get the following error in the command prompt from which I opened the SSH tunnel :

打开与localhost:21的连接以从127.0.0.1:64027转发
转发的端口已关闭

Opening connection to localhost:21 for forwarding from 127.0.0.1:64027
Forwarded port closed

至少我猜这意味着dipsy试图访问打开的SSH隧道,但是我不确定服务器端正在发生什么.看来dispynode什么也没收到. 在服务器上使用 TCPdump 运行快速的流量捕获即可确认.由于某些未知原因,端口更改为64027.

At least I guess this means that dipsy is trying to access the opened SSH tunnel but I'm not sure what's happening server side. It seems that dispynode receives nothing. Running a quick traffic capture with TCPdump on the server confirms it. For some unknown reason, the port changes to 64027.

我还尝试同时打开2个SSH隧道:

I have also tried to open 2 SSH tunnels simultaneously :

  • 一个用于客户端到服务器的通信

  • One for client-to-server communications

plink -v -ssh -L 61:localhost:21 user@myserver.net

plink -v -ssh -L 61:localhost:21 user@myserver.net

一个用于服务器到客户端的通信

One for server-to-client communications

plink -v -ssh -R 20:localhost:60 user@myserver.net

plink -v -ssh -R 20:localhost:60 user@myserver.net

但是没有运气.我什至不确定最好使用远程转发还是本地转发

but with no luck. I'm not even sure whether it is best to use remote forwarding or local forwarding

我尝试了dispy开发人员本人建议的解决方案,但对我而言不起作用:

I tried this solution that the developer of dispy himself suggested but it didn't work for me :

http://sourceforge.net/p/dispy/discussion/1771151 /thread/bcad6eaa/

我上面使用的配置是否错误?我应该使用远程还是本地转发?为什么端口会自动更改,是否可能是由于我公司的防火墙阻止了我要使用的端口进行的连接?有没有人以前设法通过SSH隧道运行dispy?

Is the configuration i used above wrong ? Should I use remote or local forwarding ? Why does the port change automatically, can it be because of my company's firewall blocking the connection through the ports i'm trying to use ? Has anyone managed to run dispy through an SSH tunnel before ?

推荐答案

这对我有用.它应该为您工作:

This worked for me. It should work for you :

  • SSH隧道(我正在使用PuTTY的 plink.exe 创建隧道):
  • SSH tunnel ( i'm using PuTTY's plink.exe to create the tunnel ):

plink -v -ssh -R 51347:localhost:51347 [服务器上的用户名] @ [服务器的公共IP或域名] -pw [服务器上的用户密码] -N

plink -v -ssh -R 51347:localhost:51347 [username on server]@[server's Public IP or DomainName] -pw [USER PASSWORD on server] -N

  • dispynode (在服务器上运行-Linux):
    • dispynode (running on the server - linux):
    • sudo dispynode.py -d --ext_ip_addr [服务器的公共IP或域名]

      sudo dispynode.py -d --ext_ip_addr [public IP or domain name of server]

      • JobCluster (dipsyClient):

        • JobCluster (dipsyClient):

          def Worker():
              os.system('echo hello') #prints hello on the server running dispynode
              return 0
          
          import os
          import dispy, logging
          
          cluster = dispy.JobCluster( \
              Worker, \
              nodes=['IP public or domain name of server'], \
              ext_ip_addr='localhost', \
              recover_file='recoverdispy.rec', \
              )
          
          job = cluster.submit()
          print "waiting for job completion"
          job()
          print('status: %s\nstdout: %s\nstderr: %s\nexception: %s' % (job.status, job.stdout, job.stderr, job.exception))
          

        • 尝试这段代码..确保允许使用所需的端口

          Try this piece of code .. Make sure the required ports are allowed to be used

          这篇关于通过SSH隧道将Dispy与端口转发一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆