Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 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@1.2.3.4:path/to/newRead.txt

where 1.2.3.4 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
    
I'm pretty sure he meant .local to refer to the mDNS domain, not a folder name on his computer. –  cjm Jan 17 '12 at 13:32
    
@cjm Thanks, I edited the answer to something less ambiguous. –  Herman Torjussen Jan 17 '12 at 13:41

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

Your Answer

 
discard

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.