SSH forwarding based on ports


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH forwarding based on ports
# 1  
Old 05-24-2013
SSH forwarding based on ports

Hi guys, I'm trying to set up an Ubuntu VPN server that will forward an ssh connection automatically as a proxy to two separate LAN hosts.
What I'm looking at doing is making SSH listen on two ports (if that is possible) and get some kind of script, preferably something in bash, that will listen on those two ports and forward the connection to whichever host in the event of a successful connection.

Eg:

P 22 >> Host 1
P 4000 >> Host 2

The two hosts are running red Hat linux and a Windows variant and will be accessed initially from both Linux and Windows machines.
I was looking at getting ssh to listen on the separate ports by editing the
Code:
/etc/ssh/sshd

to add for example, port 4000 underneath port 22 and restart the service.

At the minute I have it all running on Amazon ec2.

Any ideas?
# 2  
Old 05-24-2013
Why not use proxycommand and nc to connect to lan hosts:

You would use something like this on your external .ssh/config

Code:
host proxy_server
user therk1
hostname your.domain.com
port 22
host lan1
proxycommand ssh -q proxy_server nc lan1
host lan2
proxycommand ssh -q proxy_server nc lan2

You can then just ssh to proxy_server,lan1 and lan2 hosts from the command line
# 3  
Old 05-24-2013
VPN does not seem to be a need. No reconfiguration of sshd is necessary, either. Of course, the sshd on the far end must allow the tunnel type.

If you set up a tunnel with SSH, listening on one end and connecting out to some target host-port on the other, anyone who can get to the listener can use the target, as long as it is not a tcp protocol that acts on hosts and ports in the message stream, like FTP, and even that can be accommodated with additional tricks in many cases. Unlike the shell command part of the ssh session, user id is not in play, it is just a tcp wormhole you created. BTW, if the session has compression, so do the tunnel connections.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Ssh port forwarding through a pseudo terminal

Here's a situation: I do all my work on a Mac. I have mysql installed on my mac. 1. There's a certain linux server 'server01' that provides access to another linux server 'server02' via a pseudo terminal So, to ssh into 'server02', I do this from my mac: ssh -t server01... (1 Reply)
Discussion started by: imperialguy
1 Replies

2. IP Networking

Help me understand ports and port forwarding please

I have a few questions below on ports. From my understanding ports are what allow information to come into your computer and each port interprets/allows specific information/data to come in. Is this correct from a ball park perspective? If not could some elaborate on this please. What... (1 Reply)
Discussion started by: syregnar86
1 Replies

3. IP Networking

Ftp over SSH port forwarding

Hi, I'm trying to connect ftp over ssh port forwarding to a sever(UnixC) behind FireWall(F/W). here's my env and question. UnixA(SSH Client) ----F/W ---- UnixB(SSH Svr) ---- UnixC (FTP, 21) UnixA wants to connect ftp service of UnixC via SSH port forwarding on UnixB. Unix A,... (3 Replies)
Discussion started by: hanyunq
3 Replies

4. IP Networking

Totally stucked in ssh port forwarding

Hello my friends , i am totally stuck in ssh port forwarding topic i had learn iptables and other networking topic without any problem but ssh port forwarding is headache 1. local port = what is this ? is this incoming traffic or outgoing traffic 2. remote port = same as above 3. dynamic... (2 Replies)
Discussion started by: rink
2 Replies

5. UNIX for Advanced & Expert Users

SSH X forwarding question

Hi, Local PC - Ubuntu 11.04 desktop Remote PC - Debian 6.0 desktop My problem is 2 desktops, remote and local, are displayed on the same workplace on local PC. It would be quite confusing. Is there any way to display each desktop on one workplace(on its own workplace) OR displaying both... (0 Replies)
Discussion started by: satimis
0 Replies

6. UNIX for Advanced & Expert Users

Forwarding based on keywords in sendmail

I have an application that runs on the server with root privileges and all emails it sends get sent to root (errors, logs, etc), when they should actually go to one of application admins. I would like to separate these emails from the OS related one sent to root and forward them to that... (2 Replies)
Discussion started by: vostrushka
2 Replies

7. UNIX for Dummies Questions & Answers

SSH port forwarding/tunneling

So this seems like something that should be simple...but I can't quite seem to get it up and running. I have a machine, .107 with a GUI on port 8443. The problem is that I can't connect directly to .107 from my laptop. Now I have another machine, .69 that can connect to .107. So shouldn't I be able... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

8. Shell Programming and Scripting

SSH Tunnel Forwarding with no shell

Hi Experts, I am trying to have the SSH tunnel Remote forwarding command in a shell script. I should be able to do 2 tasks, but unable to get that going. 1) I have 3 servers Server 1, Server 2, Server 3. I have my Database running on Server 1 and my script running on Server 2 which should... (0 Replies)
Discussion started by: Scriptingglitch
0 Replies

9. Cybersecurity

ssh X-forwarding and remote forwarding behind proxy

Hi, from my workplace we use a proxy to connect to the outside world, including external ssh servers. The problem is that the server is seeing the connection coming from the proxy and knows nothing about the client behind it. The ssh connection itself works fine, but x-forwarding does not work as... (1 Reply)
Discussion started by: vampirodolce
1 Replies

10. OS X (Apple)

ssh forwarding to X11

Hi, I have issues with running graphical interfaces on my computer being remotely logged into a network via the -X option of ssh. My .cshrc shows DISPLAY=hostname:0 and I think there should be a different number instead of the 0. I changed the ssh_config file already to 'X11 forwarding yes', which... (0 Replies)
Discussion started by: ginese
0 Replies
Login or Register to Ask a Question