I have my MAC on a wifi and am connected via ssh to a linux host. I want to copy some files from the linux host over to my MAC. I know, I can simply run scp on the mac to fetch each file via

mac> scp me@host.some.where:remote/folder/file local/folder

but I cannot do that with one command for many files (I could tar them first into an archive using the ssh connection and then ship the archive in one go, but I want to avoid this). So instead, I want to send all the files from the remote host (to which I'm connected by ssh) via (note the usage of a wildcard)

host> scp remote/folder/files* me@mac.some.where:local/folder

but what is the appropriate mac.some.where here, i.e. how can I obtain that, when my MAC is connected to some wireless? I tried the (numerical) IP address (obtained by ifconfig), but to no avail.

  • scp remote/folder/files* me@W.X.Y.Z:local/folder ought to work, where W.X.Y.Z is the IP address of the Mac, unless there's a firewall blocking ssh, or the Mac is behind a router that's using NAT, or there's no ssh daemon running on the Mac. What error message do you get? Can you ping the Mac from the Linux host? – Mark Plotnick Aug 29 '14 at 15:36
  • No that didn't work (error: ssh: connect to host ... port 22: Connection refused). I tried to ping (using the IP address, but ping simply hangs). – Walter Aug 29 '14 at 15:58
  • Connection refused usually means the remote system is reachable but there's no daemon listening on that particular TCP port. @vaaaal has the two logical options: you can enable the ssh server on the Mac, or you can pull the files over by typing scp on the Mac. (I'd put quotes around the filename that ends in * so that the Mac shell doesn't try to expand it.) – Mark Plotnick Aug 30 '14 at 23:48

I would continue to use your computer as a the local machine and put the wildcard on the remote host side by running the following command on your MAC:

mac> scp me@host.some.where:remote/folder/file* local/folder

If you really want to log in to your machine from the remote host here is a brief guide. The wi-fi connection you are on is likely over a local area network (LAN) and the remote host is probably operating over the internet as a whole which, from your Mac's perspective, is the wide area network (WAN). The IP address you are seeing with ifconfig is almost certainly your LAN address and not the WAN address that the remote host needs. If you open up your terminal and run curl http://myip.dnsomatic.com; echo; you should be able to see the WAN IP address of your LAN. This will only get you to your LAN's router though, you will likely need to explicitly tell the router to forward ssh traffic (on port 22 by default) to your particular computer using the LAN IP address of your Mac that you obtained with the ifconfig command. As Mark Plotnick mentioned you will also need to be sure that SSH is turned on on your Mac (system preferences -> sharing -> remote login & file sharing) and that there are no firewalls between you and the remote servers blocking incoming traffic on port 22. Lastly, be very careful opening your computer up to the internet like this and turning on remote log in. It's not very safe to do this over the default port 22, especially without configuring some more advanced security options. At the very least make sure your administrative users all have strong passwords and I would turn off remote login and file sharing whenever you don't need it.

Wikipedia had nice descriptions of LAN and WAN that might be worth looking over.

| improve this answer | |
  • You cannot use the wildcard for a remote file. – Walter Aug 29 '14 at 17:12
  • I tested it on from my machine (OSX-10.9) on two different remote hosts and it worked perfectly. The remote servers were running OSX-10.6 and Ubuntu 10.04.4 LTS with sshd versions OpenSSH_6.2p2 and OpenSSH_5.3p1, respectively. Are you sure your system doesn't support it? – Reed Espinosa Aug 29 '14 at 19:21
  • This may have to do with the local system exploding the wildcard locally instead of sending it over. How can that be avoided? – Walter Apr 16 '18 at 15:04

Ok, first of all the linux host MUST have the SSH service on.


host$ /etc/inist.d/ssh status
* sshd is running

Then you MUST have to have connection to the SSH port of the host

mac$ telnet <IP.of.the.host> 22
Trying X.X.X.X ...
Connected to X.X.X.X
Escape Character is 

Then you could be able to scp FROM/TO the host

scp -P <PORT> <source> <destination>


scp -P 22 user@x.x.x.x:/home/user /home/user

If you don't have the SSH service running or permission to ssh the host, you wouldn't be able to make any kind of ssh connection

Remember, scp makes the connection though SSH service

| improve this answer | |
  • As I've said, I ssh from the mac to the remote host. – Walter Aug 29 '14 at 17:14
  • Ok, then telnet remote host ip to ssh port to see if you have connection – tachomi Aug 29 '14 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.