Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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?
 

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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.
 

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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:
 

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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
 

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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.
 

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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?
 

Tex-Twil

macrumors 68030
May 28, 2008
2,501
15
Berlin
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.




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
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

;)
 

abel75

macrumors newbie
Feb 26, 2009
4
4
Amsterdam, NL
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.
 

Tex-Twil

macrumors 68030
May 28, 2008
2,501
15
Berlin
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.
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

;)
 

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
4
51.50024, -0.12662
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. …

correct.

Issue this command line on your mac:

Code:
MacBook-Pro:$ scp -r [email]thorm004@cis-lab.ml.unisa.edu.au[/email]:private/pij1/pracs ~/

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.

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.

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.
 

Tex-Twil

macrumors 68030
May 28, 2008
2,501
15
Berlin
So did it work ?

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.

I guess it is because of one of those reasons:

- 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
;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.