1819927 Members
3043 Online
109607 Solutions
New Discussion юеВ

Nohup with scp

 
wojtek75
Frequent Advisor

Nohup with scp

Hi,

I would like to use nohup with scp command. I can't use public key auth but password. I run it this way:

nohup scp /tmp/data.dbf user@host:tmp
user@host's password:

After I deliver correct password the scp transmission starts. After that I put it to the background (Control-Z) and restart the transmission with fg %1. Files still keep
on being transferred. But as soon as I leave the session the scp job terminates. Why?

I can't use
nohup scp /tmp/data.dbf user@host:tmp &
because then I have no password prompt.

I also tried to use a script:

====scp.sh=====
trap "" HUP
scp /tmp/data.dbf user@host:tmp
===============

and run it as
nohup ./scp.sh

but the problem still exists. After logout the transfer stops.

The general question is: how can I keep scp session after logout on condition that I have to put the password at the beginning?

I would appreciate any help.
5 REPLIES 5
Olivier Masse
Honored Contributor

Re: Nohup with scp

If this is always a manual intervention and nohup doesn't work, you could try screen, it might work. If it's not available on your server, grab it from here:
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/screen-4.0.3/

I haven't used this in years, but from what I remember, you need to run screen, start your scp, then detach with CTRL-A,D. Logout as you please. Then come back later, and reattach to your virtual terminal using "screen -r".

wojtek75
Frequent Advisor

Re: Nohup with scp

This is a production server and screen is not available and not allowed to be install. I need another solution.
Olivier Masse
Honored Contributor

Re: Nohup with scp

I could be wrong but it might be an old bug in portable SSH which was fixed, but some problems remain on HP-UX. See the last few comments about it here:
https://bugzilla.mindrot.org/show_bug.cgi?id=52

A possible alternate solution for you to run this in the background would be to use certificates so that you do not have to input a password, then launch it with "at now". At will run your scp, and you can logout.
D Block
Advisor

Re: Nohup with scp

cat <
wojtek75
Frequent Advisor

Re: Nohup with scp

Olivier,

which part of the suggested link you are suggest? I can't find your point. And certificates are unable to use in my case.

D_Block,

scp does not readm from stdin.

Still waiting for any solution. What about trapping HUP? Any working example would do.