Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

hardened gentoo - reverse ssh tunnel

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
10 posts • Page 1 of 1
Author
Message
zxy
Veteran
Veteran
User avatar
Posts: 1160
Joined: Fri Jan 06, 2006 8:07 am
Location: in bed in front of the computer
Contact:
Contact zxy
Website

hardened gentoo - reverse ssh tunnel

  • Quote

Post by zxy » Sat Nov 10, 2007 1:36 pm

I run a box with hardened genoo linux (server).
I can ssh to i with no problems.

I need to do the following:
from some other machine (client), i need to ssh to user somebody on server, but with ability to create a reverse tunnel.

I created a user somebody and ssh-ing to it works. but when i do

Code: Select all

ssh -l somebody -R 2222:localhost:22 server.mybox.org
on the client machine i get an error:

Code: Select all

Warning: remote port forwarding failed for listen port 2222
My problem is, that if i connect with -R ... to the root the reverse tunnel works ok, but it doesn't work when i connect with -R ... to user somebody.

I guess it's some permission thing.

Help appreciated.
Nature does not hurry, yet everything is accomplished.
Lao Tzu
Top
zxy
Veteran
Veteran
User avatar
Posts: 1160
Joined: Fri Jan 06, 2006 8:07 am
Location: in bed in front of the computer
Contact:
Contact zxy
Website

  • Quote

Post by zxy » Mon Nov 12, 2007 9:48 pm

*bump*
Nature does not hurry, yet everything is accomplished.
Lao Tzu
Top
Hu
Administrator
Administrator
Posts: 24401
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Mon Nov 12, 2007 10:52 pm

Is somebody allowed to run servers? If you are using the GRsecurity patches, you may have restricted the creation of listening sockets to privileged users. See "Socket restrictions" in the GRsecurity subsection of menuconfig.
Top
linuxkrn
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 140
Joined: Mon Oct 13, 2003 3:08 am
Location: Denver,Colorado
Contact:
Contact linuxkrn
Website

  • Quote

Post by linuxkrn » Tue Nov 13, 2007 7:40 pm

You must be root to bind a listening port on < 1024.

Try adding a port above 1024 and try again. (sshd_config, you can have more then one port)

Code: Select all

-R 2222:localhost:2323 foobar
Top
Hu
Administrator
Administrator
Posts: 24401
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Tue Nov 13, 2007 11:46 pm

linuxkrn wrote:You must be root to bind a listening port on < 1024.

Try adding a port above 1024 and try again. (sshd_config, you can have more then one port)

Code: Select all

-R 2222:localhost:2323 foobar
No, he is doing it right. According to the ssh documentation, the first number is the port to bind on the peer and the second number is the port to which the local ssh should connect when a forwarding is used. He is binding port 2222 on the remote end and directing ssh to connect to port 22 locally when the forwarding is used.
Top
linuxkrn
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 140
Joined: Mon Oct 13, 2003 3:08 am
Location: Denver,Colorado
Contact:
Contact linuxkrn
Website

  • Quote

Post by linuxkrn » Wed Nov 14, 2007 1:37 am

No, he is doing it right. According to the ssh documentation, the first number is the port to bind on the peer and the second number is the port to which the local ssh should connect when a forwarding is used. He is binding port 2222 on the remote end and directing ssh to connect to port 22 locally when the forwarding is used.
Hu, if you think that binding < 1024 is incorrect, I suggest you dig in the code.

From the man page (man ssh)
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to
be forwarded to the given host and port on the local side. This
works by allocating a socket to listen to port on the remote
side, and whenever a connection is made to this port, the connec-
tion is forwarded over the secure channel, and a connection is
made to host port hostport from the local machine.

Port forwardings can also be specified in the configuration file.
Privileged ports can be forwarded only when logging in as root on the remote machine.
Again, privileged ports are < 1024.
Top
truc
Advocate
Advocate
User avatar
Posts: 3199
Joined: Mon Jul 25, 2005 9:24 am

  • Quote

Post by truc » Wed Nov 14, 2007 8:24 am

again 2222>1024
The End of the Internet!
Top
Hu
Administrator
Administrator
Posts: 24401
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Thu Nov 15, 2007 1:55 am

linuxkrn wrote:
No, he is doing it right. According to the ssh documentation, the first number is the port to bind on the peer and the second number is the port to which the local ssh should connect when a forwarding is used. He is binding port 2222 on the remote end and directing ssh to connect to port 22 locally when the forwarding is used.
Hu, if you think that binding < 1024 is incorrect, I suggest you dig in the code.

Again, privileged ports are < 1024.
Yes, ports less than 1024 are privileged. Did I ever say that he was binding a privileged port? I specifically walked through his command to show how he is not binding a privileged port. He is binding a non-privileged port and instructing ssh to connect to port 22, which is perfectly legal for a non-privileged user to do.
Top
manaka
Apprentice
Apprentice
User avatar
Posts: 178
Joined: Mon Jul 23, 2007 7:09 pm
Location: Spain

  • Quote

Post by manaka » Fri Nov 16, 2007 8:45 pm

As Hu pointed, it's a grsec issue. There are some grsec special user groups that can be defined when configuring the kernel. Users belonging to this group are denied/permitted "special" things.

The *default* values for the GIDs usually conflict with the values used by useradd when creating users. Check that your unprivileged user doesn't belong to the 1002 group (socket-server).

To avoid this issues, I suggest creating the following groups before adding users (be aware that Portage may also add users/groups when emerging a package).

grsec-proc:x:1001:
grsec-socket-server:x:1002:
grsec-socket-client:x:1003:
grsec-socket-all:x:1004:
grsec-tpe:x:1005:
grsec-audit:x:1007:

Hope this helps!
Javier Miqueleiz

"Listen to your heart. It knows all things, because it came from the Soul of the World, and it will one day return there."
Top
zxy
Veteran
Veteran
User avatar
Posts: 1160
Joined: Fri Jan 06, 2006 8:07 am
Location: in bed in front of the computer
Contact:
Contact zxy
Website

  • Quote

Post by zxy » Fri Nov 16, 2007 8:59 pm

Thanks for so many replies. I'll test them tonight sometime and report back..

It's pentium2 machine so it might take some time for testing. :roll:
Nature does not hurry, yet everything is accomplished.
Lao Tzu
Top
Post Reply

10 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic