Networking Forums

Networking Forums > Computer Networking > Linux Networking > sftp and ssh a machine behind a router

Reply
Thread Tools Display Modes

sftp and ssh a machine behind a router

 
 
bird
Guest
Posts: n/a

 
      06-02-2006, 03:23 PM
Hi every one,

I have a couple of machines sharing a broadband
connection through a router at home. Each machine
as an IP number as 192.168.2.x. One machine has
Fedora Core (FC) installed. Everything is fine
until recently when I need to access the FC machine
when I am out of town.

The FC machine has daemon sshd running, and I can
access it by sftp and ssh on any machine at home.
My question is how I can access it on a machine
outside of my router?

I did try to connect the FC machine directly to
the broadband (bypassing the router), and I was
able to ssh and sftp the FC machine from a public
one successfully. However, by this way my other
machines at home did not have internet access
any more.

Can any one please tell me how I can keep the FC
machine behind my router while let it accessible
by internet? Thank you.

-Kevin
 
Reply With Quote
 
 
 
 
notbob
Guest
Posts: n/a

 
      06-02-2006, 04:14 PM
On 2006-06-02, bird <(E-Mail Removed)> wrote:
>
> Can any one please tell me how I can keep the FC
> machine behind my router while let it accessible
> by internet? Thank you.


Look up port forwarding on google.

nb
 
Reply With Quote
 
buck
Guest
Posts: n/a

 
      06-02-2006, 05:26 PM
On Fri, 02 Jun 2006 11:23:07 -0400, bird <(E-Mail Removed)> wrote:

>Hi every one,
>
>I have a couple of machines sharing a broadband
>connection through a router at home. Each machine
>as an IP number as 192.168.2.x. One machine has
>Fedora Core (FC) installed. Everything is fine
>until recently when I need to access the FC machine
>when I am out of town.
>
>The FC machine has daemon sshd running, and I can
>access it by sftp and ssh on any machine at home.
>My question is how I can access it on a machine
>outside of my router?
>
>I did try to connect the FC machine directly to
>the broadband (bypassing the router), and I was
>able to ssh and sftp the FC machine from a public
>one successfully. However, by this way my other
>machines at home did not have internet access
>any more.
>
>Can any one please tell me how I can keep the FC
>machine behind my router while let it accessible
>by internet? Thank you.
>
>-Kevin


Maybe with something like this?
# This allows access to A when VNC connects to Z:
#A="192.168.1.76"
#Z="external.ip.address"
# Tear down
iptables -D FORWARD -p tcp -d 192.168.1.76 --dport 5900 -j ACCEPT
2>/dev/null
iptables -D FORWARD -p tcp -d 192.168.1.76 --dport 5500 -j ACCEPT
2>/dev/null
iptables -t nat -D PREROUTING -p tcp -d external.ip.address \
--dport 5501 -j DNAT --to 192.168.1.76:5500 2>/dev/null
iptables -t nat -D PREROUTING -p tcp -d external.ip.address \
--dport 5901 -j DNAT --to 192.168.1.76:5900 2>/dev/null

# Set up
# This is the key! Redirect from external to internal whatever
# port(s) - 22 in your case?
iptables -t nat -I PREROUTING -p tcp -d external.ip.address \
--dport 5901 -j DNAT --to 192.168.1.76:5900
iptables -t nat -I PREROUTING -p tcp -d external.ip.address \
--dport 5501 -j DNAT --to 192.168.1.76:5500

# You must allow the packets through the FORWARD chain:
iptables -I FORWARD -p tcp -d 192.168.1.76 --dport 5900 -j ACCEPT
iptables -I FORWARD -p tcp -d 192.168.1.76 --dport 5500 -j ACCEPT

You may also want to check out the REDIRECT target. I avoid it
because it did not correctly compile so it causes Seg Faults. DNAT
works so I use it.
--
buck

 
Reply With Quote
 
Unruh
Guest
Posts: n/a

 
      06-02-2006, 05:51 PM
buck <(E-Mail Removed)> writes:

>On Fri, 02 Jun 2006 11:23:07 -0400, bird <(E-Mail Removed)> wrote:


>>Hi every one,
>>
>>I have a couple of machines sharing a broadband
>>connection through a router at home. Each machine
>>as an IP number as 192.168.2.x. One machine has
>>Fedora Core (FC) installed. Everything is fine
>>until recently when I need to access the FC machine
>>when I am out of town.


Short answer-- you cannot. Those private addresses are non-routable on the
public network.
Longer answer, if your router, is able to do port forwarding, then you can
set it up so that if you try to ssh to say port 22 on the router IP
address, it will automatically send on the packet to port 22 on your
internal machine. Whether or not your router allows port forwarding and how
to enable it will require a trip to your router manual.


>>
>>The FC machine has daemon sshd running, and I can
>>access it by sftp and ssh on any machine at home.
>>My question is how I can access it on a machine
>>outside of my router?


What your FC machine has or does is irrelevant. Packets cannot reach it.

>>
>>I did try to connect the FC machine directly to
>>the broadband (bypassing the router), and I was
>>able to ssh and sftp the FC machine from a public
>>one successfully. However, by this way my other
>>machines at home did not have internet access
>>any more.
>>
>>Can any one please tell me how I can keep the FC
>>machine behind my router while let it accessible
>>by internet? Thank you.
>>
>>-Kevin



NOthing you do on the FC machine can change the situation. packets cannot
reach it because it has a private address which will be thrown away at the
first public router they reach.


>Maybe with something like this?
># This allows access to A when VNC connects to Z:
>#A="192.168.1.76"
>#Z="external.ip.address"
># Tear down
>iptables -D FORWARD -p tcp -d 192.168.1.76 --dport 5900 -j ACCEPT
>2>/dev/null
>iptables -D FORWARD -p tcp -d 192.168.1.76 --dport 5500 -j ACCEPT
>2>/dev/null
>iptables -t nat -D PREROUTING -p tcp -d external.ip.address \
> --dport 5501 -j DNAT --to 192.168.1.76:5500 2>/dev/null
>iptables -t nat -D PREROUTING -p tcp -d external.ip.address \
> --dport 5901 -j DNAT --to 192.168.1.76:5900 2>/dev/null


># Set up
># This is the key! Redirect from external to internal whatever
># port(s) - 22 in your case?
>iptables -t nat -I PREROUTING -p tcp -d external.ip.address \
> --dport 5901 -j DNAT --to 192.168.1.76:5900
>iptables -t nat -I PREROUTING -p tcp -d external.ip.address \
> --dport 5501 -j DNAT --to 192.168.1.76:5500


These would work if he had two ethernet cards on that single machine, one
of which was connected tot he external world. He has a router.


># You must allow the packets through the FORWARD chain:
>iptables -I FORWARD -p tcp -d 192.168.1.76 --dport 5900 -j ACCEPT
>iptables -I FORWARD -p tcp -d 192.168.1.76 --dport 5500 -j ACCEPT


>You may also want to check out the REDIRECT target. I avoid it
>because it did not correctly compile so it causes Seg Faults. DNAT
>works so I use it.
>--
>buck


 
Reply With Quote
 
IcessLinux
Guest
Posts: n/a

 
      06-04-2006, 05:51 PM
You actually can, here's how:

Register a DNS at NO-IP and get yourself the Linux NO-IP client (google
for no-ip, i can't remember the URL now). Once you have installed it
and added it to the neccesary RC(startup) scripts on the machine you
want to access, you should enable your gateway to forward the SSH port
(can't remember it now, think it's 23) to the machine your'e running it
on. This can be a huge security risk if the proper precautions are not
taken so please do some more reading up. Your router/gateway should be
setup properly aswell as anyone could then connect to your registered
DNS and they would end up on your Gateway if no ports are forwarded by
defualt for port 80. So setup your firewall on the router/gateway
properly and disable all not needed services on the PC running SSHD.

Constant Meiring

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Synology 107+ arm openssh-sftp Maf-Kees Linux Networking 0 06-18-2008 09:57 AM
How to get sftp more secure? tech11 Linux Networking 1 10-17-2007 11:27 AM
[sFTP] automatic authentication polemon Linux Networking 2 02-25-2007 08:56 PM
SFTP packet? Peter Linux Networking 1 02-16-2005 09:00 AM
SFTP & FTP transfert rate Paul Linux Networking 4 05-28-2004 01:11 PM



1 2 3 4 5 6 7 8 9 10 11