Forums

Skip to content

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

ssh tunnel and scp transffer ?

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
raptor
Apprentice
Apprentice
Posts: 171
Joined: Fri Sep 20, 2002 11:04 am

ssh tunnel and scp transffer ?

  • Quote

Post by raptor » Tue Oct 24, 2006 4:31 pm

hi,

I'm doing something like this :

Code: Select all

ssh -l user -L 9999:remote-ip:8888  gateway-ip  scp -P9999 remote-user@localhost:/remote-dir/*  /local-dest/dir
When I try this I'm getting the following error :

Code: Select all

ssh: connect to host localhost port 9999: Connection refused
If instead of 'scp', I use f.e. 'cat -' to preserve the tunnel open and from another terminal I issue the 'scp' command everything is ok.
My interpretation is that when I call 'ssh ... scp ...' the tunnel closes imediatly after it is created and that is why following 'scp' command gives an error that it cannot connect to this port at the localhost.
The problem is that I want to do this in a script, which means it will be a headache 'cause I have to fork a process to open up the tunnel and then run the scp command and after that I have to kill this forked process...

So my question is there is an easier way to preserve the tunnel at least untul the scp command finish ??

thank you very much ...
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 Oct 24, 2006 6:25 pm

Just use job control...

Code: Select all

#!/bin/bash

ssh -N .....  &

scp ...
more stuff here

kill %1
Top
raptor
Apprentice
Apprentice
Posts: 171
Joined: Fri Sep 20, 2002 11:04 am

ssh tunnel and scp transffer ?

  • Quote

Post by raptor » Tue Oct 24, 2006 9:05 pm

still doesn't seem to work.. i.e. probably 'cause it goes to background it asks for password three times very quick w/o a chance to answer!
and no tunnel is created..

i.e.

Code: Select all

user@gate password:
Permission denied, please try again.
user@gate password:
Permission denied, please try again.
user@gate password:
Permission denied, please try again.
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 Oct 24, 2006 11:37 pm

Use ssh keys. "man ssh-agent"
Top
raptor
Apprentice
Apprentice
Posts: 171
Joined: Fri Sep 20, 2002 11:04 am

getting process id

  • Quote

Post by raptor » Wed Oct 25, 2006 5:45 pm

linuxkrn wrote:Use ssh keys. "man ssh-agent"
In my case I could not do this, but I found a solution to the problem i.e.

Code: Select all

ssh -f -N ......
do the job.

But doing it this way I can't get the process id of the 'ssh', so that I can kill it ?
Is there easy way to do this, instead of tring something like this :

Code: Select all

ps xa | grep 'ssh -f' | cut -f 2..!!
which my not do the job in more complex scenario !?
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 Oct 25, 2006 8:49 pm

Besides that command being dangerous (killing the wrong process), you're not going to be able to ssh without a password or pass phrase.

Why is it you cannot use pass phrases? You can always use one without a password.

For security, you cannot pass a password to ssh via pipe or input redirect. Therefore you must use either tty input or a pass phrase to connect.
Top
raptor
Apprentice
Apprentice
Posts: 171
Joined: Fri Sep 20, 2002 11:04 am

thanx

  • Quote

Post by raptor » Wed Oct 25, 2006 8:53 pm

linuxkrn wrote:Why is it you cannot use pass phrases? You can always use one without a password..
because there is many accounts on many servers...different ppl.. it is a little headache..:)

thanx for your help..
Top
Post Reply

7 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