LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-03-2010, 09:31 AM   #1
ernst
Member
 
Registered: May 2006
Location: Sydney
Distribution: Debian etch, SkoleLinux
Posts: 77

Rep: Reputation: 15
ssh port forwardin in ssh_config


I would like to have a permanent ssh forwarding of the form

ssh -f -N -L9112:localhost:9102 example.org

'man ssh' says that this can be specified in the /etc/ssh/ssh_config
file. I tried this:
Code:
Host example.org
#LocalForward [bind_address:]port host:hostport
LocalForward 9112 example.org:9102
I did expect that with 'service sshd restart' the forwarding will be set up. But it does not. 'man ssh_config' doesn't give examples, so I am not sure what is wrong.

Thanks
Ernst
 
Old 02-03-2010, 12:47 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well restarting SSHD will make no difference in the slightest, as that's the server, and you're trying to modify the client, which is totally unconnected.

The config looks OK to me, add a few -v's to the command line and read the debugging for what it thinks of the config.
 
Old 02-03-2010, 01:02 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
I think you just need to actually create the tunnel:
Code:
ssh example.org
And then the tunnel will be created as you specified in the ssh_config (you could also put it in your ~/.ssh/config).
Evo2.
 
Old 02-03-2010, 01:06 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Erm... yeah... you are actually sshing to the remote server right???
 
Old 02-04-2010, 01:31 AM   #5
ernst
Member
 
Registered: May 2006
Location: Sydney
Distribution: Debian etch, SkoleLinux
Posts: 77

Original Poster
Rep: Reputation: 15
Good I can see now that restarting the sshd was just wishful thinking.

But won't
Quote:
ssh example.org
just open an ordinary ssh connection
without setting up a port forwarding?
In other words how do I tell the client to set up forwarding using the information from the ssh_config
 
Old 02-04-2010, 01:34 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Erm... that's the point of putting the config in the ssh_config file...
 
Old 02-04-2010, 02:09 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
When you "ssh example.org", the line "Host example.org" in your ssh_config will match it and the port forwarding rules you specified will be applied, so that you don't have to explicitly type out "ssh -L 9112:localhost:9102 example.org" to create the tunnel.

Normally I would use a "made up" host name for the "Host" line, otherwise, each time you just want to ssh to example.org ssh will try to create another tunnel.
eg
Code:
Host exampleTunnel
   LocalForward 9112 example.org:9102
Then you can create the tunnel with "ssh exampleTunnel", and if you just want to ssh there as normal you can still do "ssh example.org."

HTH,

Evo2.
 
1 members found this post helpful.
Old 02-04-2010, 03:57 AM   #8
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
The file:

/home/username/.ssh/config settings will take precedence over /etc/ssh/ssh_config.
 
Old 02-04-2010, 10:14 PM   #9
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
Quote:
I would like to have a permanent ssh forwarding of the form

ssh -f -N -L9112:localhost:9102 example.org
instead of doing in sshd_config here is the easy way which is
you need to define sleep mode

Code:
ssh -f user@remote.org  -N  -L9112:localhost:9102  sleep 365d
this will keep your connection for 1 years

Last edited by routers; 02-04-2010 at 10:17 PM. Reason: typo
 
Old 02-07-2010, 04:53 AM   #10
ernst
Member
 
Registered: May 2006
Location: Sydney
Distribution: Debian etch, SkoleLinux
Posts: 77

Original Poster
Rep: Reputation: 15
Thank you everyone,
My confusion is easing a little.
I did like the tip
Quote:
Normally I would use a "made up" host name
will remember that one.
I will also try the
Quote:
sleep 365d
Actually I use this to use bacula.org for backups. It uses port 9101, 9102 and 9103.
Rather than opening the firewall I try to tunnel through ssh. Although I can now establish those forwardings it seems to be rather fragile. Like after about 1GB I get:
Quote:
JobId 232: Fatal error: append.c:243 Network error on data channel. ERR=No data available
 
  


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 get /etc/ssh/ssh_config changes to stick CoffeeKing!!! Linux - Security 3 01-30-2009 01:09 AM
Howto do Secured ssh from port https or port80(standard) to ssh d listening port 22 ? Xeratul Linux - General 4 11-23-2006 06:09 AM
I installed openssh for redhat 7.3 but no /etc/ssh/ssh_config file was made akay Linux - Networking 1 11-15-2004 05:19 PM
Regarding /etc/ssh/ssh_config (CLUSTERS) nedian123 Linux - Networking 1 08-14-2004 05:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:32 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
Open Source Consulting | Domain Registration