Arnold Roa
Arnold Roa

Reputation: 7718

Is possible to copy files over ssh during an active connection

Very often I need to copy a file from a ssh connection. Lets say a mysql dump. what I do is

local $ ssh my_server
server$ mysqldump database >> ~/export.sql
server$ exit
local $ scp myserver:~/export.sql .

I know ssh has a lot of features like ssh-agent, port-forwarding, etc, and I was wondering if there is anyway to execute scp FROM the server to copy to my local computer (without creating another ssh connection).

Upvotes: 2

Views: 383

Answers (1)

Jakuje
Jakuje

Reputation: 25966

First of all, this question is off-topic here, so it will be migrated or put on hold early.

Anyway, I described the solution for similar problem here, but it should help you: https://stackoverflow.com/a/33266538/2196426

Summed up, yes it is possible using remote port forwarding:

[local] $ ssh -R 2222:xyz-VirtuaBox:22 remote
[remote]$ scp -P 2222 /home/user/test xyz@localhost:/home/user

Upvotes: 1

Related Questions