ssh forwarfing start as daemon

Does anyone have experience of configuring I ssh forwarding as daemon in linux ? pls share your configuration
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ssh forwarding is not a daemon.  There is no configuration that I know of in the SSH daemon to automatically bring up a tunnel or forwarding.

Also, when you start forwarding a port from one system to another (I am assuming that is what your doing) it is user done as a user.

Can you give an example of what your trying to do?  Also make sure to give more details in all your questions, it will help us help you. (example: what flavor/version of Linux your using, what you are trying to accomplish, what you tried already, etc...)
AXISHKAuthor Commented:
I'm running Redhat 5.

There are two servers,  
      ServerA     -->   ServerB (MySQL server)

I want to put this to run everything when the server boot up.
ssh -fNg -L 3306:localhost:3306 sciadm@mysqlserver

I try autossh but it doesn't work.

You can create an init script and place it in /etc/init.d/

Once you've created a script, named forwardssh in this,

    Enable the script

     chkconfig --add forwardssh
     chkconfig --level 2345 forwardssh on

    Check the script is indeed enabled - you should see "on" for the levels you selected.

     chkconfig --list | grep forwardssh

Taken from a site I can't link to here. /questions/20357/how-can-i-make-a-script-in-etc-init-d-start-at-boot

# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
    # code to start app comes here 
    # example: daemon program_name &

stop() {
    # code to stop app comes here 
    # example: killproc program_name

case "$1" in 
       # code to check status of app comes here 
       # example: status program_name
       echo "Usage: $0 {start|stop|status|restart}"

exit 0 

Open in new window

Google for "place a script in init.d"

You could make it really simple and not check anything, but you'll have problems later when you want to control the startup through the script.
ssh -fNg -L 3306:localhost:3306 sciadm@mysqlserver
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

AXISHKAuthor Commented:
To clarify, I create a file under /etc/init.d/forwardssh  and put my script here.

Afterwards, chkconfig --add forwardssh

Do I need to specifyc a full path, or linux can find it when adding under /etc/init.d  ?

for chkconfig --level 2345 forwardssh on , will that mean linux will create the symbolic link such as the following,  
  /etc/rc0.d/K20blah -> /etc/rc.d/init.d/blah
   /etc/rc1.d/K20blah ->  /etc/rc.d//init.d/blah

Do I l need to create a link ? Is it a hard or soft link ?  Tks
You should not have to do anything further.  You can check that it was added with the following command.

 chkconfig --list | grep -i forwardssh
chkconfig should have added the links for you when you set the levels.

You should be able to
chkconfig --list forwardssh

Piping to grep should be redundant, but I'm not sure if that's new or if that has always existed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AXISHKAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSH / Telnet Software

From novice to tech pro — start learning today.