LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-16-2007, 02:20 PM   #1
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Rep: Reputation: 15
Ssh connection to a firewalled machine.


Hi everyone
i have the need to connect via SSH a machine that is behind a firewall and a nat,
which i can't change, open ports and so on.
how can i do that?
i was thinking to something like a script that checks if the ssh tunnel is on, otherwise tries to connect to my external machine, but i have no clue how to set ssh server to connect like "active mode".
moreover everything should be using RSA key auth..

in short the problem is this:
machine A is at my home
machine B is at work
machine B is behing a firewall and a nat which i can't change
i want to be able to control machine B from machine A.
how to do? is it possible?

Thanks alot!
 
Old 06-16-2007, 03:24 PM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: Caldera, CTOS, Debian, FreeBSD, Mac OS X, Mandrake, Minix, OpenBSD, Slackware, SuSE
Posts: 1,757

Rep: Reputation: 80
Quote:
i have the need to connect via SSH a machine that is behind a firewall and a nat, which i can't change, open ports and so on.
If the firewall won't allow port 22 connections and/or redirect SSH connections to a host behind the firewall, then you can't connect. You'd have to talk to your work System/Network Admin to see if either they will allow the SSH connection or possibly they have VPN access. Maybe some else has another idea?
 
Old 06-16-2007, 03:29 PM   #3
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Original Poster
Rep: Reputation: 15
nope is not possible to open any port in the firewall, then i am afraid i am locked off...
 
Old 06-16-2007, 05:29 PM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,357

Rep: Reputation: 213Reputation: 213Reputation: 213
A solution would be that the machine B checks periodically a http page, to give it a triggering to start a ssh on your port 80 or 8080 of your home machine A. Or reverse ssh ...?
(I suppose machine B has only 80 or 8080 as open ports)

No ideas much, but that could be possible for any Pros !

and what about this: http://img503.imageshack.us/my.php?i...lbypassdy9.jpg
(from http://www.linuxquestions.org/questi...hread.php?t=55)

Last edited by Xeratul; 06-16-2007 at 05:31 PM.
 
Old 06-17-2007, 05:05 AM   #5
SlackDaemon
Member
 
Registered: Mar 2006
Distribution: RedHat, Slackware, Experimenting with FreeBSD
Posts: 222

Rep: Reputation: 30
Try perl-reverse-shell or cryptcat to reverse connect to the external host. Assuming your firewall allows outbound connections.

http://pentestmonkey.net/tools/perl-reverse-shell/

If you must use ssh, lookup the -R option in order to make a reverse connection with ssh.

Last edited by SlackDaemon; 06-17-2007 at 05:07 AM.
 
Old 06-17-2007, 09:15 AM   #6
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Original Poster
Rep: Reputation: 15
thanks slackdaemon
that is exactly what i was studying yesterday..
ssh -f -R 1234:localhost:22 user@remote.host in fact i am free to have outbound connections..
i wanted crond to check every hour for example that the ssh tunnell is still on, then if not restore it..
of course i should use RSA key with no passphrase..
how can i set crond? and what about rsa with no passphrase? would it be a security issue?
suggestions?

ps: i need some security so reverse-shell is out of question (also cuz i can't install apache or lightppd) but since i don't have any knowledge about cryptcat..i can't choose it..
would it be good for this case?

Last edited by assasukasse; 06-17-2007 at 09:20 AM.
 
Old 06-17-2007, 10:00 AM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,357

Rep: Reputation: 213Reputation: 213Reputation: 213
Quote:
Originally Posted by assasukasse
thanks slackdaemon
that is exactly what i was studying yesterday..
ssh -f -R 1234:localhost:22 user@remote.host in fact i am free to have outbound connections..
i wanted crond to check every hour for example that the ssh tunnell is still on, then if not restore it..
of course i should use RSA key with no passphrase..
how can i set crond? and what about rsa with no passphrase? would it be a security issue?
suggestions?

ps: i need some security so reverse-shell is out of question (also cuz i can't install apache or lightppd) but since i don't have any knowledge about cryptcat..i can't choose it..
would it be good for this case?
Are you sure that you can have this outbound port 22 through the firewall ? They usually block it. ...
Im am curious why they didnt just allow port 80/8080 for surfing only.
 
Old 06-17-2007, 10:01 AM   #8
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Original Poster
Rep: Reputation: 15
yes i am sure since i connected with ssh to my home machine..
i am experimenting with cryptcat, and i am able to connect a remote server.
however i am unable to start any command..but every command i issue is echoed in the remote window..

i started a listening server with
cryptcat -l -vv -p 1350 -k password on my home machine
then
on the remote
cryptcat -k password hostname_of_my_home 1350

it does connect, but i can't launch any command

ok i found why, debian cryptcat doesn't support the -e command..
so is cut out, even if it was perfect for the use i need..

Last edited by assasukasse; 06-17-2007 at 10:10 AM.
 
Old 06-17-2007, 01:57 PM   #9
xenocide87
LQ Newbie
 
Registered: Jun 2007
Location: USA
Distribution: Slackware
Posts: 3

Rep: Reputation: 0
Quote:
Originally Posted by assasukasse
Hi everyone
i have the need to connect via SSH a machine that is behind a firewall and a nat,
which i can't change, open ports and so on.
how can i do that?
I was thinking that a VPN program like Hamachi would be great for this, but you would need admin. privileges on the work system to install Hamachi. You could try talking to your Network/Sys. Admin. and see if they'd approve of a VPN program. If not, then I'm afraid I'm out of ideas for the moment.

If anyone wants to know what Hamachi is/how it works, here's the link: https://secure.logmein.com/products/hamachi/
 
Old 06-17-2007, 02:48 PM   #10
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Original Poster
Rep: Reputation: 15
i do have admin privilege on my work system
i don't have privileges to stop change or open ports on the university NAT-firewall
I will give a look into hamachi, when i get how it works..

hamachi is still super bothersome..
having to create and user, to chmod a file..
what if i am not on pc, and it reboots?
i should make a script..
then i can just script ssh...

I will consider hamachi for multiple user connected to a virtual network, otherwise is no need to bother.

Last edited by assasukasse; 06-17-2007 at 04:53 PM.
 
Old 06-20-2007, 12:58 PM   #11
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Original Poster
Rep: Reputation: 15
hamachi doesn't pass tru the firewall
ssh tunnel does, but seems not reliable, most of the time my tunnel gets killed..only works at night
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't SSH to remote machine: Connection closed by remote host Avatar Linux - Networking 35 10-23-2017 01:21 AM
Cannot SSH to remote firewalled terminal? ajeetraina Linux - Networking 1 06-14-2007 09:27 AM
Connecting to firewalled SSH server BlueTornJacket Linux - Networking 3 02-04-2007 10:06 AM
Keep losing connection to remote machine through SSH/VNC cav Linux - Networking 3 04-23-2006 08:12 PM
ssh connection from a Windows machine to a Linux machine pistachio Linux - Networking 1 08-30-2005 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration