How can I download files from Linux to my Mac OS using only the existing ssh connection?

I know if I use the Windows System, I can use lrzsz to down files:

yum install lrzsz
sz file // there can use the `sz` download file to windows

but this is not apply to macOS.

If macOS is in a public IP address environment, I can use the scp to copy it, but there is a NAT, I can not do it.

  • A way would be to create a VPN containing the Mac and SSHing (sftp or any other utilities to transmit files) into it after connecting to the VPN from the Linux machine, do you have this possibility ? You would need to be able to open a port in your firewall, as well as installing a VPN server utility – Jean Rostan May 21 at 9:43
  • 2
    You can use scp even if your Mac is behind a NAT (as long as the Linux server has a known IP address, or if you configure port forwarding in your router). But right now your question is rather broad, there are a lot of potential answers which may or may not help you. What exactly is your setup, how often do you want to copy data, where do you initiate the transfer (on the sending Linux side or on the receiving macOS side)? – nohillside May 21 at 11:10
  • I agree with no hillside - the portion of the question can use the scp to copy it. but there is a NAT, I can not do it makes this look entirely like a networking problem and nothing to do with a software recommendation problem. The help center has guidance on editing this to show some research and define what "not apply" and "can not do it" mean more precisely. – bmike May 21 at 11:17
  • The serial connection file transfer programs (which go over the ssh character flow) can be used even if nothing else is possible. If you cannot install sz (using XCode command line tools which has the c compiler) you can have a closer look at Kermit (which require a little bit of tuning to utilize the connection best) – Thorbjørn Ravn Andersen May 21 at 11:23
  • He's asking to download - i.e. he's running scp on the Mac in order to copy from the Linux machine. It won't by itself work when the Linux machine is behind NAT - he'll need to create a port forward in order to get that working. But Dropbox or similar handles NAT by way of design, so that's easier to get working. – jksoegaard May 21 at 11:37

You can actually the sz program for downloading to a Mac as well.

If you want to be able to run scp on your Mac to download files from the Linux machine when it is behind NAT, you'll need to setup a port forward in your router to forward your public IP address port 22 to port 22 on the Linux PC's local IP-address. You'll then enter the public IP address when running scp on your Mac.

However a perhaps more "user friendly" option is to use a service such as for example Dropbox. If you install that on both your Linux computer and Mac, you can send files back and forth that way without worrying about NAT.

Another option is to use VPN-software to connect both your Linux and Mac to the same virtual network. Then you can use scp as you're already using on the local network to copy files.

  • VPN and Dropbox may not be technically or politically possible if this is a restricted, hosted Linux instance – Thorbjørn Ravn Andersen May 21 at 11:25
  • Ofcourse, but OP has not written anything about having a restricted, hosted Linux instance - so why worry about problems that might not be there. – jksoegaard May 21 at 11:35
  • Sure, but then why use sz in the first place? – Thorbjørn Ravn Andersen May 21 at 12:47
  • That's just speculation. It might be a program he knew in the past and used for that reason alone. We'll need more information from the OP if he is indeed dealing with downloaded from a restricted environment. – jksoegaard May 21 at 13:35
  • In that case, that is speculation as well. Let's see what edits come along. – Thorbjørn Ravn Andersen May 21 at 14:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .