Skip to main content
Post Closed as "Duplicate" by slm, Anthon, Karlson, Gilles 'SO- stop being evil', jasonwryan
added 89 characters in body
Source Link
Max
  • 129
  • 1
  • 5

Instead of thisFrom my local machine I can copy files from a remote machine

scp remote:/some/file/path ~

But what if I'm already SSHed into the remote machine? Can I would like to do something like this:

ssh remote
cd /some/file
scp path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?

Instead of this

scp remote:/some/file/path ~

I would like to do something like this:

ssh remote
cd /some/file
scp path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?

From my local machine I can copy files from a remote machine

scp remote:/some/file/path ~

But what if I'm already SSHed into the remote machine? Can I do something like this

ssh remote
cd /some/file
scp path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?

remove distracting example
Source Link
Max
  • 129
  • 1
  • 5

Suppose I want to copy a really tricky path to my home directory

cp /really/complicated\ \&/annoying/path ~

Dealing with typos in the path can be really annoying, so sometimes it's nice to cd a bit to shorten the offending path.

cd /really
cd complicated\ \&
cp annoying/path ~

If the source file is on a remote server, it gets even worse because you have to double escape everything for scpInstead of this

scp remote:/really/complicated\\\ \\\&some/annoyingfile/path ~

What would be really nice is if I couldwould like to do something like this:

ssh remote
cd /really
cd complicated\ \&some/file
scp annoying/path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?

Suppose I want to copy a really tricky path to my home directory

cp /really/complicated\ \&/annoying/path ~

Dealing with typos in the path can be really annoying, so sometimes it's nice to cd a bit to shorten the offending path.

cd /really
cd complicated\ \&
cp annoying/path ~

If the source file is on a remote server, it gets even worse because you have to double escape everything for scp

scp remote:/really/complicated\\\ \\\&/annoying/path ~

What would be really nice is if I could do something this:

ssh remote
cd /really
cd complicated\ \&
scp annoying/path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?

Instead of this

scp remote:/some/file/path ~

I would like to do something like this:

ssh remote
cd /some/file
scp path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?

Source Link
Max
  • 129
  • 1
  • 5

scp to Local Machine After SSHing

Suppose I want to copy a really tricky path to my home directory

cp /really/complicated\ \&/annoying/path ~

Dealing with typos in the path can be really annoying, so sometimes it's nice to cd a bit to shorten the offending path.

cd /really
cd complicated\ \&
cp annoying/path ~

If the source file is on a remote server, it gets even worse because you have to double escape everything for scp

scp remote:/really/complicated\\\ \\\&/annoying/path ~

What would be really nice is if I could do something this:

ssh remote
cd /really
cd complicated\ \&
scp annoying/path local:~

where local somehow resolves to the machine I SSHed from. This would of course be possible if the local machine is running an SSH server and the remote is configured to connect to it, but that isn't always an option.

Is something like this possible?