Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

Is it possible to transfer files (client-server) from inside a ssh session?.

I know how to transfer files using SCP, This question is about transference from inside a ssh session. For example I start the ssh session:

ssh root@example.com

I perform some operations

echo "Test" > FILE

I transfer the files (pseudocode)

remotecp FILE client_directory

I want to know this because I want to make an automation script from some process (mostly backup operations) and I want to make it the most atomic way possible.

share|improve this question

marked as duplicate by jasonwryan, Anthon, devnull, slm, goldilocks Apr 12 at 15:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
scp is the command to do that. If you set up a ssh key, then you can automate it. –  Elliott Frisch Apr 12 at 1:57
    
I guess it depends if you running your client with a external IP address or not. If so, who mom hates show your IP –  RSFalcon7 Apr 12 at 2:45
    
@ElliottFrisch: I know that method, I want to know if there is a way to do it without closing sessions like the example above. –  S182 Apr 12 at 3:16
1  
@Serge Probably with some kermit hack. –  Elliott Frisch Apr 12 at 3:28
    
@jasonwryan: You are right, that question is what I needed. Sorry I did some research but I miss that one. –  S182 Apr 12 at 5:52
add comment

1 Answer 1

If you are running your client with a external IP address:

IP=$(who mom hates | awk '{print $5}' | tr -d ')' |tr -d '(')
scp FILE USER@${IP}:~/some/path
share|improve this answer
    
Thanks, but not external IP address. –  S182 Apr 12 at 3:10
1  
Interactively you can suspend the connection with '~&' but I do not think this would work for scripts –  RSFalcon7 Apr 12 at 3:16
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.