F
F
Forever Extreme2020-10-22 07:47:03
linux
Forever Extreme, 2020-10-22 07:47:03

How to download a file from the server while on the server?

Hello! Tell me how to download a file from the server after I connected to it via ssh?
I know what I can type in the console while in the home directory
scp [email protected]:/home/file.txt ~/Downloads
And what command should I enter while in the terminal on the server! And not in the home directory
No matter how much I googled, they write everywhere about the command entry from the home console
. A small addition! The server has a white ip, my computer does not

Answer the question

In order to leave comments, you need to log in

8 answer(s)
P
Pavel Shvedov, 2020-10-22
@mmmaaak

Instead of the usual connection to the server via ssh, and trying to download something from its console, you can use this trick:

ssh [email protected] 'tar c .' | tar xvf - -C /home/username

D
Dmitry Aleksandrov, 2020-10-22
@jamakasi666

You can do this. If I understand correctly from the question.
When connecting via SSH, you do port forwarding through it.
And your PC.
B server.
connect via ssh from A to B, do port forwarding from B (conditionally 222) to A (ssh port). This is indicated when connecting.
After connecting, already on machine B, you can give
scp foobar.txt [email protected]:222:/some/remote/
directory you are on a remote server through an ssh tunnel forwarding a port to ssh your PC and you can connect via ssh \ scp back to it.
Wise but possible.

S
shurshur, 2020-10-22
@shurshur

The task is to ensure that on the server it would be possible to open an ssh connection to a computer located behind nat somewhere in the office. And it can be done! For this, ssh has Port Forwarding.
We do this:
ssh -R 12345:127.0.0.1:22 [email protected]
This not only opens a session with example, but also on a remote server on localhost (127.0.0.1) sshd starts listening on port 12345. All connections to this port via ssh -connection (that is, they are encrypted encrypted on the source machine at 127.0.0.1:22. As required.
For example, you can go to your own machine on a remote machine:
ssh -p 12345 [email protected]
You can copy the file:
scp -P 12345 /dev/zero [email protected]
You can even sftp:
sftp -o Port=12345 [email protected]
It is possible to forward the port in the opposite direction, from the local machine to the remote one, using the -L switch. For example, let's say there is a server in the office with an external IP, from which the internal address 192.168.1.2 is available with Windows and RDP enabled. We need to get to it without bothering with raising the VPN.
We do this:
ssh -L 31415:192.168.1.2:3389 [email protected]
Then, in the RDP client, instead of 192.168.1.2, enter 127.0.0.1:31415
PS: It should be noted that PortForwarding can be disabled in the sshd settings. But most often in the default configuration it is enabled.

M
Max, 2020-10-22
@7workers

when you logged in via SSH, you seem to be sitting at the screen and keyboard of the server and at the same time you do not know anything about the existence of your home computer. so you need to do scp from the server to the home one, with all the consequences, so to speak. in short, this is not "out of the box", this is "dancing with a tambourine"

A
Alexander, 2020-10-22
@shabelski89

With current knowledge it is easier to use WINSCP which will connect via sftp and you will have a user friendly interface.
Examples of console commands here

A
antonwx, 2020-10-22
@antonwx

FileZilla download and through it already download anything

Z
Zzzz9, 2020-10-22
@Zzzz9

Guess why there are so many answers and no one can help?, because there is no complete picture. Specify which operating systems, if the network is local, this is one thing, if the global network is different, the addresses are white gray, the scheme is better.

V
Victor Taran, 2020-10-22
@shambler81

the easiest way for one-time transfers is simply on your mc to connect to external ssh
and copy by handles.
login and password how to enter I think you know.
5f916e6e87713949213591.png
Actually, any of the FTP SFTP SSH protocols will do (well, FTP must be present on the other side)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question