copy directory to Mac from remote SSH

Discussion in 'macOS' started by richard.mac, Mar 11, 2009.

  1. richard.mac macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #1
    how do i copy a directory from my universities server to my Mac using SSH in Terminal? i assume you use cp with -r to copy a directory but im not sure about the rest.

    also if i want to retain the permissions of all the files inside do i use -p as well?
     
  2. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #3
    thanks for the link.

    so whats my 'yourusername' and 'yourserver'? would i enter scp -r -p directory_name rich@my_external_IP_address?

    ive done that and turned on Remote Login which i assume i need and the prompt returns, but i cannot see the copied directory anywhere.
     
  3. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #4
    it'd be something like

    scp -r rich@richs_server name_of_directory_you_want_on_your_computer

    :)

    This website actually explains it a lot better.
     
  4. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #5
    ok i dont get the "rich@richs_server" bit above. would it be my home directory's username or my Mac's name and then my Mac's external IP?… because my Mac isnt a webserver or anything.

    when i try it with my username and external IP it returns the prompt but my copied directory is nowhere to be seen on my Mac.

    bear with me here ;):eek:
     
  5. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #6
    (I deleted this because it was wrong; scroll to the end of the thread for the solution)
     
  6. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #7
    yep its a Sun server that all the students do their practical work on.

    so i tried this and there was an error.

    Screencapture 2.png
    click for full size
     
  7. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #8
    Hmm, I assume you have read permissions on that directory...?
     
  8. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #9
    yes i have read & write permissions

    Code:
    Last login: Wed Mar 11 20:03:03 on ttys000
    MacBook-Pro:~ rich$ ssh -l thorm004 cis-lab.ml.unisa.edu.au
    Password: 
    Last login: Wed Mar 11 20:03:12 2009 from ppp121-45-58-21
    
            SunOS 5.10 Generic      137112-01       May 2008
    
    thorm004@cis-lab ~ $ cd private/pij1/pracs
    thorm004@cis-lab pracs $ ls -al
    total 15
    drwx------ 2 thorm004 students    8 Mar 11 18:18 .
    drwx------ 3 thorm004 students    3 Mar 11 19:34 ..
    -rw------- 1 thorm004 students  462 Mar 10 10:15 BoxedName.class
    -rw------- 1 thorm004 students  199 Mar 10 10:15 BoxedName.java
    -rw------- 1 thorm004 students  752 Mar 10 20:11 TemperatureConverter.class
    -rw------- 1 thorm004 students  535 Mar 10 20:10 TemperatureConverter.java
    thorm004@cis-lab pracs $
    dont i have to enter my Mac somewhere in the mix? or dont i have to as im logged into it.
     
  9. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #10
    No, you shouldn't have to.

    Can you copy an individual file using the syntax in previous posts? Or do you get the same error?
     
  10. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #11
    if i enter
    Code:
    scp -r thorm004@cis-lab.ml.unisa.edu.au BoxedName.java
    while in the pracs directory it gives the same error:

    Code:
    cp: cannot access thorm004@cis-lab.ml.unisa.edu.au
    maybe there are no copy permissions over the internet on this server?
     
  11. Tex-Twil macrumors 68020

    Tex-Twil

    Joined:
    May 28, 2008
    Location:
    Europe
    #12
    Hi,
    it is getting a bit confusing here. If I understand correctly, you are trying to copy something from your university server to your MBP while being logged on your MBP.

    Issue this command line on your mac:

    Code:
    MacBook-Pro:$ scp -r [email]thorm004@cis-lab.ml.unisa.edu.au[/email]:private/pij1/pracs ~/
    
    I assume that
    Code:
    private/pij1/pracs
    
    is in the home directory of thorm004 on the university server.

    The
    points to the home directory on your mac but you can use any other path.




    This comes from the fact that there has to be a colon : between the IP of the server and the path:
    Code:
    scp -r thorm004@cis-lab.ml.unisa.edu.au[B]:[/B]/path/to/BoxedName.java /path/on/MBP
    ;)
     
  12. abel75 macrumors newbie

    Joined:
    Feb 26, 2009
    Location:
    Haarlem, NL
    #13
    Assuming you want to copy the 'pracs' directory across

    ssh -l thorm004 cis-lab.ml.unisa.edu.au
    cd private/pij1
    scp -r pracs <username>@<your macs external ip>:.

    The user name would be your user name on your Mac. The :. means the pracs directory will be placed in your home directory on the mac.
     
  13. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #14
    Ah, follow TexTwil's advice. I was not reading the syntax correctly and told you that you didn't need the path on your mac when in fact you did. Sorry about that. :(
     
  14. Tex-Twil macrumors 68020

    Tex-Twil

    Joined:
    May 28, 2008
    Location:
    Europe
    #15
    This will work also but :
    - you have to enable the SSH server on your mac
    - if your MBP is behind a router, you must set up port forwarding of the port 22 (ssh)
    - you must know the public IP of your mac
    - your university firewall must allow outgoing connections to port 22

    ;)
     
  15. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #16
    correct.

    aha! thats the ticket! i saw "MacBook-Pro:$" and then realised i had to do this locally and not logged into the ssh server.

    thanks for clearing up the confusion.

    when i try this with "thorm004" and my Mac's home username "rich" the prompt just hangs. so i assume you only do this locally.

    thanks for your time everyone.
     
  16. Tex-Twil macrumors 68020

    Tex-Twil

    Joined:
    May 28, 2008
    Location:
    Europe
    #17
    So did it work ?

    I guess it is because of one of those reasons:

     
  17. richard.mac thread starter macrumors 603

    richard.mac

    Joined:
    Feb 2, 2007
    Location:
    51.50024, -0.12662
    #18
    "aha! thats the ticket!" implies that it worked. you probably didnt get the Cockney colloquialism :D.
     
  18. Tex-Twil macrumors 68020

    Tex-Twil

    Joined:
    May 28, 2008
    Location:
    Europe
    #19
    ok :) I'm not a native English speaker ;)
     

Share This Page