# Redirecting SSH

**URL:** https://forum.yunohost.org/t/redirecting-ssh/25214
**Category:** Advanced use case
**Tags:** es, french, english
**Created:** [June 18, 2023, 2:13pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214 "2023-06-18T14:13:02Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 18, 2023, 2:13pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/1 "2023-06-18T14:13:03Z")

</div>

**YunoHost version:** 11.1.21.4 (stable)  
**I have access to my server :** Through SSH | through the webadmin

Hi.

My Yunohost server at home uses a public IP address from a VPN.  
In a second machine I have installed something else, which is publicly available through the Yunohost Redirect app.

What should I do to SSH into this second machine from the Internet?

Thank you!

---

<div class="post-metadata">

### Author: ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)
#### Post date: [June 18, 2023, 3:06pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/2 "2023-06-18T15:06:01Z")

</div>

i guess choosing two different SSH ports (which you can change from yunohost’s webadmin) and redirecting those ports from your router to the appropriate machines

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 18, 2023, 3:14pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/3 "2023-06-18T15:14:42Z")

</div>

The thing is I cannot redirect ports from my router. My Yunohost server is in a VPN.

I was wondering if there is any redirect I could do from the Yunhost server.

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 18, 2023, 3:55pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/4 "2023-06-18T15:55:47Z")

</div>

Maybe I didn’t explain properly.

The public IP address of my Yunohost server is in the VPN, not in my home router -I did so to have a working email server.

So in my home router I cannot do that kind of port-forwarding because the router just sees VPN-encapsulated traffic to my Yunohost server.

---

<div class="post-metadata">

### Author: ![jarod5001](https://forum.yunohost.org/user_avatar/forum.yunohost.org/jarod5001/32/5323_2.png) [@jarod5001](https://forum.yunohost.org/u/jarod5001)
#### Post date: [June 18, 2023, 7:39pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/5 "2023-06-18T19:39:03Z")

</div>

Ssh to your yunohost server and from there ssh to your other machine using its local ip

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 19, 2023, 8:17am UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/6 "2023-06-19T08:17:28Z")

</div>

Yes, thanks, ssh jumping would be a solution too, but I forgot to mention another requirement (apologies): because of administration policies, it requires independent access.

I guess I will have to configure another VPN connection to the second machine.

---

<div class="post-metadata">

### Author: ![jarod5001](https://forum.yunohost.org/user_avatar/forum.yunohost.org/jarod5001/32/5323_2.png) [@jarod5001](https://forum.yunohost.org/u/jarod5001)
#### Post date: [June 19, 2023, 10:23pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/7 "2023-06-19T22:23:24Z")

</div>

If server 1 is behind vpn then server 2 can be reached using a port forwarded in the router. Try it and if you get an error, share it

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 20, 2023, 9:56pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/8 "2023-06-20T21:56:53Z")

</div>

This is the setup: I configured a VPS on an external provider as a “VPN server”. Then I configured server 1 (my Yunohost server) as a “VPN client”. That way server 1 can use the VPS public IP address.

So I think I cannot do a port redirect in the router because all traffic (any port) to server 1 is VPN-encrypted; that is, the router cannot see traffic sent to server 1.

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 20, 2023, 10:13pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/9 "2023-06-20T22:13:57Z")

</div>

I guess another solution could be to play with iptables on the Yunohost server (server 1) to make it be the one forwarding ports to server 2.

However, as I would like to keep the Yunohost server’s configuration as standard as possible (in order to avoid future headaches), I guess I will go for the option of configuring a VPN client on server 2.

---

<div class="post-metadata">

### Author: ![BluishHumility](https://forum.yunohost.org/user_avatar/forum.yunohost.org/bluishhumility/32/8111_2.png) [@BluishHumility](https://forum.yunohost.org/u/BluishHumility)
#### Post date: [June 21, 2023, 3:58pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/10 "2023-06-21T15:58:26Z")

</div>

> [@peer](#):
>
> So I think I cannot do a port redirect in the router because all traffic (any port) to server 1 is VPN-encrypted; that is, the router cannot see traffic sent to server 1.

I think the suggestion was to leave server 1 and the VPN out of it altogether. If you set up a port forward on the router for traffic from port 22 (or whatever port you would like server 2 to use for SSH), when you SSH to the externally-facing IP address of the router it will connect you to server 2. This type of forward will have no impact on server 1 since it is using a VPN (which uses a separate port number for all traffic).

If you want to rope server 2 into the VPN like you mentioned, you certainly can but it is not needed.

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 21, 2023, 5:01pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/11 "2023-06-21T17:01:58Z")

</div>

I don’t have any static public IP address to reach the SSH service of server 2. I do have a static public IP address (the one on the VPS) to reach the web service of server 2 (done through server 1 Yunohost Redirect), and I have a DNS record pointing to it.

So, yes, I think I could do port forwarding to SSH into server 2, but only if I add a different DNS solution just for the SSH service, like DDNS.

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 21, 2023, 9:06pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/12 "2023-06-21T21:06:42Z")

</div>

Edited the message above, it had a mistake.

---

<div class="post-metadata">

### Author: ![jarod5001](https://forum.yunohost.org/user_avatar/forum.yunohost.org/jarod5001/32/5323_2.png) [@jarod5001](https://forum.yunohost.org/u/jarod5001)
#### Post date: [June 21, 2023, 9:13pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/13 "2023-06-21T21:13:53Z")

</div>

And if you install a vpn server on your yunohost and connect server 2 to it, change its ssh port to 5555 (for example) and allow this port in the yunohost firewall (in the webadmin).  
Another thing, why not use the same vpn for both servers?

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [June 21, 2023, 9:24pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/14 "2023-06-21T21:24:58Z")

</div>

> [@jarod5001](#):
>
> Another thing, why not use the same vpn for both servers?

Yes, that is what I suggested as my favorite option: Having server 2 as another VPN client (and isolating VPN clients through firewall so that they cannot talk to each other).

---

<div class="post-metadata">

### Author: ![jarod5001](https://forum.yunohost.org/user_avatar/forum.yunohost.org/jarod5001/32/5323_2.png) [@jarod5001](https://forum.yunohost.org/u/jarod5001)
#### Post date: [June 21, 2023, 9:27pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/15 "2023-06-21T21:27:39Z")

</div>

Hope it won’t break the redirect 🙄

---

<div class="post-metadata">

### Author: ![peer](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/p/e9bcb4/32.png) [@peer](https://forum.yunohost.org/u/peer)
#### Post date: [July 10, 2023, 12:34pm UTC](https://forum.yunohost.org/t/redirecting-ssh/25214/16 "2023-07-10T12:34:26Z")

</div>

> [@peer](#):
>
> I guess I will have to configure another VPN connection to the second machine.

I did it, it works.
