Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on a macbook running Lion. In Terminal I'm connected to my schools server with ssh. I navigated to a folder on the server and have a file I want to copy to my local machine, but I don't know what the IP address of my local machine is. How can I get it? I'm in the folder on the server, and I want to copy read.txt onto my local machine's hard drive. I've tried scp ./read.txt [my computer name].local/newRead.txt but it doesn't work.

share|improve this question
up vote 8 down vote accepted

You don't need to know your own host's IP address in order to copy files to it. Simply use scp to copy the file from the remote host:

$ scp user@rhost.com:path/to/read.txt ~/path/to/newRead.txt

If you want to copy to your local host from your remote host, get your own IP address with ifconfig and issue the following:

$ scp path/to/read.txt user@

where is your local IP address. A convenient way to extract a host's IP address is using this function:

ipaddr() { (awk '{print $2}' <(ifconfig eth0 | grep 'inet ')); }

where eth0 is your network interface. Stick it in ~/.bash_profile in order to run it as a regular command - ipaddr.

share|improve this answer
What if the command returns "ifconfig: interface eth0 does not exist"? – kolistivra Nov 19 '14 at 14:45

Try ifconfig. It should tell you your local IP address (on your network) for the various interfaces like WiFi and Ethernet.

share|improve this answer

Just adding to the answer, an easy way to tell your address (ip/domain), is to ssh into a computer you can ssh into, exit and then ssh back into it again. Most times, you'll see a welcome message like:

"Last login at xx:xxpm from you.domain.com/ip.ad.dre.ss"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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