You are not logged in.

#1 2012-02-12 13:09:14

DoYouSpeakWak
Member
From: Denmark
Registered: 2012-02-12
Posts: 30

Running two ssh commands at startup

Hey all

Im working on a setup were i need two ssh commands to be executed at startup. But im not sure if its posible and if so were to put these commands.

The commands looks like this

ssh -vv -N -L 5556:127.0.0.1:5556 root@192.168.1.11
ssh -vv -N -L 5555:127.0.0.1:5555 root@192.168.1.11

After they are run a password needs to be entered. Hopefully it will be posible to put a -force after each command somehow. The -vv might not be needed either.

Any ideas on how to do this ?

Wak

Offline

#2 2012-02-12 13:19:26

Awebb
Member
Registered: 2010-05-06
Posts: 6,321

Re: Running two ssh commands at startup

Look at:

man ssh-keygen
man ssh-copy-id

Offline

#3 2012-02-12 13:27:26

Damnshock
Member
From: Barcelona
Registered: 2006-09-13
Posts: 414

Re: Running two ssh commands at startup


My blog: blog.marcdeop.com
Jabber ID: damnshock@jabber.org

Offline

#4 2012-02-12 13:27:34

DoYouSpeakWak
Member
From: Denmark
Registered: 2012-02-12
Posts: 30

Re: Running two ssh commands at startup

Thx. I know those two. i could run with ssh keys instead of passwords. But the commands still needs to be ran automatically at bootup. Thats the part im not sure about.

Offline

#5 2012-02-12 13:48:20

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Running two ssh commands at startup

So you problem is not really ssh related, but rather to execute a given script/command at boot time.
Arch Boot Process - rc.local

Offline

#6 2012-02-12 13:58:51

DoYouSpeakWak
Member
From: Denmark
Registered: 2012-02-12
Posts: 30

Re: Running two ssh commands at startup

Yes and no. The ssh problem remains. How do i run a ssh command like those mentioned above with a password. When i run them in the terminal the password is prompted and i type it in. The rc.local be able to run those commands without me typing in a password, so i think the ssh commands needs to be altered before they are put in any startup script.

Offline

#7 2012-02-12 14:10:13

revellion
Member
From: Sweden
Registered: 2007-04-10
Posts: 54

Re: Running two ssh commands at startup

you would've have to run

ssh-keygen -t rsa

as root

then do

ssh-copy-id root@192.168.1.11

and then they shouldnt prompt for passwords. smile

EDIT:
also why 2 runs against the same host?, wouldn't it be better to just use 1 command?.

example:

ssh -vv -N -L 5556:127.0.0.1:5556 root@192.168.1.11
ssh -vv -N -L 5555:127.0.0.1:5555 root@192.168.1.11

becomes

ssh -vv -N -L 5556:127.0.0.1:5556 -L 5555:127.0.0.1:5555 root@192.168.1.11

?. -L statements does stack if you use em twice smile, so you can forward more than one port in the same session.

Last edited by revellion (2012-02-12 14:11:45)


Hurricane Electric Certified IPv6 Sage

CPU: Core i7-2600 @ 4.0Ghz | RAM: 16GB (4x4GB) | GFX: AMD Radeon R9 290 4096MB VRAM | HDD: 1x 120GB SATA3 Corsair SSD (~500MB/s RW), 1x SATA2 250GB, 1x SATA2 320GB, 1x 180GB SATA3 Intel SSD
*EDIT* Replaced Nvidia GTX 570 for a AMD Radeon R9 290, and added an extra SSD 180GB

Offline

#8 2012-02-12 14:39:52

DoYouSpeakWak
Member
From: Denmark
Registered: 2012-02-12
Posts: 30

Re: Running two ssh commands at startup

Thx for your info, i think keys is just the way to go. One statement is better than two, will test it out.

Offline

#9 2012-02-13 19:35:17

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Running two ssh commands at startup

DoYouSpeakWak wrote:

Thx for your info, i think keys is just the way to go.

That is what Awebb and Damnshock were trying to point out.  But it seemed like you understood those concepts.

Offline

#10 2012-02-13 19:40:07

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Running two ssh commands at startup

If you're using netcfg, one way to make sure your interface is up before the ssh commands run is to create a script like 'ssh-connect.sh' and then put this line at the end of the /etc/network.d/<profile_name> file:

POST_UP="sleep 5; su -c '~/.local/bin/ssh-connect.sh' firecat53"

Scott

edit: oh, and definitely go with ssh-keys/(ssh-agent|keyring)!!

Last edited by firecat53 (2012-02-13 19:42:30)

Offline

Board footer

Powered by FluxBB