LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-15-2011, 09:02 PM   #1
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Rep: Reputation: 0
Failed SSH tcp forwarding


I want to create a tunnel from my home computer to a linux server by SSH, then i can use the tunnel as a tcp forwarding proxy(SOCK 5) to access the web via the linux server.
But i got "Internet Explorer cannot display the webpage" on my home computer, and when i check the "/var/log/secure" in the linux server(fedora), I found:
"sshd[17926]: error: connect to xx.xx.xx.xx port 80 failed: Permission denied"

How can i solve this problem? Thanks in adv.
 
Old 05-16-2011, 12:29 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Can you post the steps you're using to create the tunnel ?
 
Old 05-16-2011, 02:45 AM   #3
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: 0
I just use the ssh server included in fedora.
"service sshd start".

Then i use the "putty" or "myentunnel" in the home computer.

I can use putty login in the fedora server via ssh, and i set the tunnel in the putty config .

I also try the "myentunnel" as the ssh client, and the log show :
"[15:43:53 05/16] plink.exe: Sent password
[15:43:53 05/16] plink.exe: Access granted
[15:43:53 05/16] plink.exe: Local port 7070 SOCKS dynamic forwarding
[15:44:00 05/16] Connection is stable
"

But when i use browser via the proxy 127.0.0.1:7070, it doesn't work.
I check the log file in the fedora server,the i found:
"sshd[17926]: error: connect to xx.xx.xx.xx port 80 failed: Permission denied"
 
Old 05-16-2011, 04:33 AM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Just a thought, but check in your sshd_config and make sure you don't have a line like the following:
Quote:
AllowTcpForwarding no
 
Old 05-16-2011, 05:06 AM   #5
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Noway2 View Post
Just a thought, but check in your sshd_config and make sure you don't have a line like the following:
Thanks. I have checked the sshd_config and found the following:
AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes

so i think i have already turn the allow tcp forwarding on.
 
Old 05-16-2011, 10:20 AM   #6
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
If you use SOCKS, this must be setup in the browser network setup instead of specifying a port for the URL. Are you just forwarding port 7070 to a remote machine or setting up SOCKS in putty?
 
Old 05-16-2011, 10:34 AM   #7
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Reuti View Post
If you use SOCKS, this must be setup in the browser network setup instead of specifying a port for the URL. Are you just forwarding port 7070 to a remote machine or setting up SOCKS in putty?
Yes, I use the network setup in the browser opetion-network-proxy setup, and in putty, i just set the tunnel as a Dynamic prot of 7070.
As the server's log tell me :""sshd[17926]: error: connect to xx.xx.xx.xx port 80 failed: Permission denied"
I think that the request has been received by the server, but it can't open the destination web page for some reason and it can return the client machine the correct result.

But i don't know why the server can't open the remote web page and return to the proxy of putty in the client machine.
 
Old 05-16-2011, 01:12 PM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
You are accessing a webserver on the server machine itself or an external one?
 
Old 05-16-2011, 05:42 PM   #9
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Reuti View Post
You are accessing a webserver on the server machine itself or an external one?
an extrenal one.

A
 
Old 05-16-2011, 06:49 PM   #10
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Do you perchance have any sort of firewall, such as iptables running on this system that would prevent outbound traffic? It wouldn't necessarily be port 80, but could be on a higher order port.
 
Old 05-16-2011, 08:55 PM   #11
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Noway2 View Post
Do you perchance have any sort of firewall, such as iptables running on this system that would prevent outbound traffic? It wouldn't necessarily be port 80, but could be on a higher order port.
The following is iptables,i don't know whether it matters:

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
 
Old 05-17-2011, 04:06 AM   #12
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Are all external servers blocked or just one particular one?
 
Old 05-17-2011, 04:13 AM   #13
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Quote:
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
I would try removing this rule, at least as an experiment. So far it is the only thing that I can see from the discussion that could relate to the permission denied error. I think the FORWARD chain is probably the least understood of the three iptables chains which makes it difficult to say whether or not it would make a difference. With the SSH proxy, you are effectively translating from one network to another, so in that regards it is plausible that it could cause problems, but my thinking is that the proxy is happening at a software level.

I also notice you have a rule "ACCEPT all -- anywhere anywhere" is this perchance on the loop back interface? If not, the other rules below it are nullified. If it is, one thing that occurred to me is that with a socks proxy works on a higher port, but the thing is that this is on the local machine, not the server. In other words, this shouldn't impact the ability to proxy via SSH. Again, the more I think about it, with your iptables policy to ACCEPT, which is fine, you might want to temporarily flush all the rules and see if that is the behind the difficulties.

Last edited by Noway2; 05-17-2011 at 04:13 AM. Reason: fixed quote tag
 
Old 05-17-2011, 05:32 AM   #14
tjjt
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Are all external servers blocked or just one particular one?

--------------------------------------------------------

Yes, all external servers blocked.



Quote:
Originally Posted by Noway2 View Post
I would try removing this rule, at least as an experiment. So far it is the only thing that I can see from the discussion that could relate to the permission denied error. I think the FORWARD chain is probably the least understood of the three iptables chains which makes it difficult to say whether or not it would make a difference. With the SSH proxy, you are effectively translating from one network to another, so in that regards it is plausible that it could cause problems, but my thinking is that the proxy is happening at a software level.

I also notice you have a rule "ACCEPT all -- anywhere anywhere" is this perchance on the loop back interface? If not, the other rules below it are nullified. If it is, one thing that occurred to me is that with a socks proxy works on a higher port, but the thing is that this is on the local machine, not the server. In other words, this shouldn't impact the ability to proxy via SSH. Again, the more I think about it, with your iptables policy to ACCEPT, which is fine, you might want to temporarily flush all the rules and see if that is the behind the difficulties.
I try to remove all the rules in iptables , now my iptable is :
"
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
"

And then i do the same thing before, and the log ifle still says:
test1 sshd[22712]: error: connect to X.X.X.X port 80 failed: Permission denied

 
Old 05-17-2011, 07:16 AM   #15
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Can you access the external website with the server machine itself, to rule out that the problem is on your side at all.
 
  


Reply



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
[SOLVED] X11 forwarding failed doublealice Linux - Newbie 13 11-08-2018 10:54 AM
ssh -L '>channel 3: open failed: connect failed:' Luke771 Linux - Networking 14 01-24-2012 03:14 AM
TCP traffic forwarding shathil Linux - Networking 1 09-05-2009 10:46 PM
LXer: Implement load-balancing, port forwarding, and rate-limiting with shd-tcp-tools LXer Syndicated Linux News 0 09-17-2008 10:30 PM
Forwarding all TCP/IP connection to a windows gateway itaysz Linux - Networking 6 01-29-2004 01:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:10 AM.

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
Open Source Consulting | Domain Registration