简体   繁体   English

使用Netbeans远程SSH / SFTP

[英]Remote SSH/SFTP with Netbeans

I know you can set up remote connection in Netbeans or as others have suggested, mount the remote file system locally and let Netbeans read that. 我知道您可以在Netbeans中设置远程连接或者像其他人建议的那样,在本地安装远程文件系统并让Netbeans读取它。

This current set-up I have to SSH into a remote server and then SSH again into another one. 这个当前的设置我必须通过SSH连接到远程服务器,然后再次SSH到另一个服务器。

Is it possible in Netbeans to access the filesystem on the 2nd server hop? 在Netbeans中是否可以访问第二个服务器跃点上的文件系统?

I think you can setup a SSH local port forwarding on your first remote server to archive what you want here. 我认为您可以在第一台远程服务器上设置SSH本地端口转发,以便在此处存档您想要的内容。 Once ssh connection established with the first server, it will be tunnel to second server. 一旦与第一台服务器建立了ssh连接,它将通过隧道连接到第二台服务器。 Also, will be much more convenient if using SSH public key as authentication method. 此外,如果使用SSH公钥作为身份验证方法,将会更方便。

Run below command on your local (Need to keep this running) 在本地运行以下命令(需要保持此运行)

ssh -NL 2222:server2.example.com:22 server1.example.com

Test connection with ssh locally 在本地测试与ssh的连接

ssh localhost 2222

So in your case, Netbeans just need to connect to localhost port 2222. 所以在你的情况下,Netbeans只需要连接到localhost端口2222。

Ref: https://www.ssh.com/ssh/tunneling/example 参考: https//www.ssh.com/ssh/tunneling/example

That isn't answer you expect, but to big to put it in comment. 这不是你所期望的答案,而是要发表评论。

I think best solution is configure autostart some service which will create tunnel to first server on your login and bind local port (let's say 2222) to second remote server ssh port. 我认为最好的解决方案是配置自动启动一些服务,它将在您的登录时创建到第一台服务器的隧道,并将本地端口(假设为2222)绑定到第二个远程服务器ssh端口。 This is basical feature of ssh client. 这是ssh客户端的基本功能。 When you can configure Netbeans to connect to localhost:2222 and login right into second server. 当您可以配置Netbeans连接到localhost:2222并登录到第二个服务器。 You might need to use keys authentication for first server. 您可能需要对第一台服务器使用密钥身份验证。

Where are examples to make such thing. 做这种事的例子在哪里。 Like is underneath link on article 喜欢在文章链接下面

http://www.pc-freak.net/blog/start-ssh-tunnel-pc-boots-windows-alwaysup/ http://www.pc-freak.net/blog/start-ssh-tunnel-pc-boots-windows-alwaysup/

Since you can get ssh access via a daisy-chain, you can very likely use SSHFS: 由于您可以通过菊花链获得ssh访问,因此很可能使用SSHFS:

https://github.com/libfuse/sshfs https://github.com/libfuse/sshfs

Available in Debian (and therefore, likely many other distributions): 在Debian中可用(因此可能有很多其他发行版):

https://packages.debian.org/jessie/sshfs https://packages.debian.org/jessie/sshfs

As long as you have ssh keys set up properly on each server, you can daisy-chain mounting via SSHFS to the machine where your NetBeans app is running. 只要在每台服务器上正确设置了ssh密钥,就可以通过SSHFS以菊花链方式挂载到运行NetBeans应用程序的计算机上。

https://en.wikipedia.org/wiki/SSHFS https://en.wikipedia.org/wiki/SSHFS

NOTE: There are some caveats, including that SSHFS expects that it is the only mechanism used to update the filesystem, and that there is only one writer at a time. 注意:有一些警告,包括SSHFS期望它是用于更新文件系统的唯一机制,并且一次只有一个编写器。 Undesirable behavior can occur if you allow other mechanisms to change the files or directories on the target server, including data loss and/or corruption. 如果允许其他机制更改目标服务器上的文件或目录(包括数据丢失和/或损坏),则可能会发生不良行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM