首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >代理Ssh服务器,该服务器位于我家的vps之上

问代理Ssh服务器,该服务器位于我家的vps之上
EN

Server Fault用户
提问于 2022-07-22 11:22:46
回答 1查看 340关注 0票数 0

我想通过Dedipath的VPS代理我的家庭SSH服务器,但是我不知道它是如何工作的。因为我已经和许多tcp代理一起尝试过了,但是它们没有工作。

我的VPS有Debian 10和我的主服务器。

EN

回答 1

Server Fault用户

发布于 2022-07-22 13:40:14

如果我假设您的家庭服务器位于NAT之后,而您的VPS具有公共internet IP,则可以使用ssh远程隧道选项:

  • 在您的主服务器上,为隧道和ssh键区创建一个专用用户:
代码语言:javascript
复制
useradd -m tunneltovps
sudo -u tunneltovps -i
ssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... tunneltovps@myhome-server


* on your VPS server, create a dedicated user for the tunnel with home-server, and copy the public key to `~/.ssh/authorized_keys`:
```shell

用户添加-m myhomeserver

数独-u myhomeserver -i

mkdir .ssh

AAAAC3NzaC1lZDI1NTE5AAAA 25519.tunneltovps@myhome-服务器>> ~/..ssh/授权密钥

代码语言:javascript
复制
复制




- on the home-server, test the connexion:

​

```javascript

数多-u隧道-i

ssh -R 1234:localhost:22 my-vps-server

代码语言:javascript
复制
复制




Now, on your VPS the port 1234 should be listening (on localhost) and tunneling to your ssh server on myhome-server




you can test to connect to your home-server from any machine connected to internet by using the VPS as a jumphost:




​

```javascript

ssh -J my- -p服务器-p 1234本地主机

代码语言:javascript
复制
复制




Alternatively, if you want to expose publicly the ssh server of my-home-server, you could use this command to create the tunnel on the home-server:




​

```javascript

ssh -R 0.0.0.0:1234:localhost:22 my server

代码语言:javascript
复制
复制




Now your home-server could be reachable directly (without jumphost) with:




​

```javascript

ssh -p 1234 my-vps-server

代码语言:javascript
复制
票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1106299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档