I'm on a Mac running Catalina. I have a file on a remote server that I want to do things with on my local machine; I want to do it so that I am moving from remote to local.

I looked at this post, this post, and many similar online resources and saw that I need to use my username and address, and then a filepath; what I am wondering is how I find these, and which I use? I have only seen "replace-with-your-info" templates, but not examples of what it should look like.

I am asking about this part

[email protected]:path/to/newRead.txt

, but with my information replaced with the generic info.

When I tried ifconfig, several blocks of phrases and numbers came up; which should I use (if any)? I also don't know how to find my username, nor what my path should look like (should the username be the full result of the hostname command, and the start of the path the result of printing the working directory from home (~)?)

Are there commands I can input into the command line that will give me these directly, or give me a formatted string of what my (local) specific part should look like?

I am asking for remote to local because my privileges on the remote are more limited, although I am open to hearing about similar things on that end as well.

  • Please edit your question and add more details: How do you connect and log in to the remote system? In which way is it restricted that it would not allow to use scp on the local machine? Depending on your local network and router it may require some configuration on your side or might not be possible to reach your local machine from the remote server. Show the output of ifconfig in your question. The real IP addresses are important, at least the first two numbers of the IPv4 address must not be changed. Describe your local network, internet connection and connection to the remote server.
    – Bodo
    Jan 28, 2021 at 21:01
  • Is the output of ifconfig not sensitive information? I thought maybe I shouldn't post it because of that? Jan 28, 2021 at 21:05
  • If there's no sshd program running on that server, or you don't have a shell account on that server, you won't be able to access the files there with scp at all. Having an email/ftp/cpanel/web/sftp-accessible account on that server is not enough.
    – user313992
    Jan 28, 2021 at 21:08
  • To get a step nearer to an answer if it is possible to reach your local system from a remote server we need to find out if you have a public or private IP address. If you can answer this we don't need to see your IP address(es). See en.wikipedia.org/wiki/Private_network Based on your question I thought this might be difficult for you. Please explain in your question why is it legitimate that you want to copy files from a server you access using an exploit? Don't forget to provide the other requested information in your question.
    – Bodo
    Jan 28, 2021 at 21:28
  • Yes, I'm not too familiar with a lot of this, as dirkt said it is probably not possible. As for if it's private, my local network has IPv4 specifications. I say good faith because it's in the context of a site that hosts CTF-like questions that some others and I am exploring. I'm sure the "accidental passthru exploit" is intentional and they want us snooping around. I wanted to know if there was a way to get the files from the site to my local machine just because it'd be easier to work with and use software on; I thought the more general question would make more sense but I guess not. Jan 28, 2021 at 22:17

2 Answers 2


So you want to copy something from a remote machine to your local mac? You can do this like so:

# from your local mac machine
$ scp <username>@<remote-hostname>:/path/to/thing/to/copy .
# or if its a directory
$ scp -r ...

This will copy the file to your current working directory (hence .)

To get the username and hostname of the remote machine, simply login and run whoami and hostname (assuming the remote machine is of linux flavor)

# e.g. 
$ ssh remote-hostname
$ hostname 
# prints machine hostname
$ whoami
# prints your username 

fwiw, assuming you already know how to ssh into this remote machine, then you already know what the hostname is for scp :)

Some extra info:

scp is nice to start with, but rsync might be a better choice depending on what types of copying/syncing work you are doing. E.g. you could try:

# from local mac
$ rsync -auvz <username>@<remote-hostname>:/path/to/folder/ .

rsync used like this will compress files before/after sending, and will take into account the variation between your local and remote folder structure, only updating what needs to be (so idempotent vs scp which is not)

  • Your answer is one of the most helpful; whoami is the kind of command I was looking for, and the other things you said were useful. I'm afraid my specific problem might be a bit too weird and people here won't be able to help, but thanks for your response. Also, do you know how to do it from the remote machine, and if it can be done without the remote user/host (I'd imagine with the local user and host instead)? I'm not using ssh as I said in some other comments, so I understand if it's not possible. I only have guesses for the exact remote user/host, which is why I ask. Jan 28, 2021 at 22:30

I have a file on a remote server

So the remote server has a name, say remote.server.com, and you have an account on the remote server, say god. You know where the file on the remote server is, for example in under home directory of god in directory files with name myfile.

Then you, from your Mac,

scp [email protected]:files/myfile localfile

and it will copy the remote file as localfile to your Mac.

ifconfig will tell you exactly nothing about the remote server.

If you don't know your account name god on the remote server, then you don't have an account on the remote server. So then the first thing you need to do is get an account. How to do that depends on you you came to have a file on remote.server.com in the first place, which you didn't tell us anything about. Usually it involves asking whoever manages the remote server.

I'm (good faith) accessing a terminal through a passthru exploit, where I can see different directories and files through an input field meant to do something else on the site.

So it's a web server, and you don't have an account on the server, which means you cannot use scp. End of story.

If you are doing this in good faith, that means you should know who runs the server, so you can contact them to get an account.

  • I didn't put the context because it's a bit niche; I'm (good faith) accessing a terminal through a passthru exploit, where I can see different directories and files through an input field meant to do something else on the site. I did log-in to the site, so I do have a username. I'm just not sure how to see the remote.server.com or my username for this context because it's more barebones and I don't know the commands to check. I thought it would be easier to just try to send the file off than to extract it, but if there are commands I can use to find these things that would be helpful. Jan 28, 2021 at 21:12
  • Is remote.server.com just the address of the website? Jan 28, 2021 at 21:12

You must log in to answer this question.

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