3

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 [email protected]

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.

S182
  • 387
  • 1
  • 3
  • 7
  • scp is the command to do that. If you set up a [ssh key](https://help.ubuntu.com/community/SSH/OpenSSH/Keys), then you can automate it. – Elliott Frisch Apr 12 '14 at 01: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 '14 at 02: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 '14 at 03:16
  • 1
    @Serge Probably with some [kermit](http://www.kermitproject.org/) hack. – Elliott Frisch Apr 12 '14 at 03:28
  • @jasonwryan: You are right, that question is what I needed. Sorry I did some research but I miss that one. – S182 Apr 12 '14 at 05:52

1 Answers1

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
RSFalcon7
  • 4,367
  • 6
  • 30
  • 56