setting up an scp or sftp server

i am very new to macs (3 months) and i am trying to set up a server to access files remotely and found this archived thread to help me...

http://discussions.apple.com/thread.jspa?messageID=8661076&#8661076

i have some questions though and since its archived i cant ask them there...

i dont understand everything i need to enter into the terminal. especially the "/path/to/dir/or/file" and the "/path/to/home" portions. im pretty sure the first one is used to direct me to the file i want to share when i login but not sure what the second one is for, and therefore not sure what to put there. i have a dyndns account so i get that part but not sure about the username.

also, not sure about the discussion regarding mac account passwords. is that the password i have on my mac? the one i have to enter when i install apps? or is that a password i assign to my server for login? just not sure.

i am also not sure how to actually login to a scp or sftp server using a client but im sure i can figure that part out.

thanks for any help!

20" iMac 2.4ghz, Mac OS X (10.5.6)

Posted on Feb 21, 2009 8:41 AM

Reply
5 replies

Feb 21, 2009 9:48 AM in response to admach

Where is the computer that is going to be the server? At home? Then you need to set up port forwarding in your home router to route ssh/sftp/scp traffic to port 22 of the "server" computer. In order to do that, refer to your router's user manual or you might be able to find something about your router at portforward.com. Every router does it differently so it is difficult to give cookbook instructions on how to do that without knowing the exact model and make of your home router, and then I probably don't have one like you do unless you rent your modem/router from the same ISP as I rent mine from.

Then you need to go to system preferences > sharing and check the remote login checkbox. Configure your authorized users as desired. Generally speaking, I would only allow authorized users with standard accounts and not with admin privileges, just from a computer and network security viewpoint.

Also, in sys prefs > security > firewall, you need to choose something OTHER than "Allow only essential services." I would suggest you use "set access for specific services and applications." ssh should be in the list of allowed services. sftp and scp are included within the ssh application so they will be allowed, too.

Good deal about already having dyndns up and running. So it is safe to assume that you have installed the DynDNS Updater application on the server computer, right?

Lastly, review the topic thread at http://discussions.apple.com/click.jspa?searchID=-1&messageID=6880415. One of my posts in there is focused strictly on ssh and scp. Not so much on sftp, but the same commands like "put" "get" "ls" "cd" "lcd" and so on that are ftp-centric they are all the same in sftp, it is just that the transmission medium is encrypted. To log in, it is just
sftp {usernameOfValidAcctOnHomeComputer}@{yourDynDNShostname}
Then use the usual (s)ftp commands. I think the username that you are questioning is the user account on the ssh/scp/sftp server as who you will be logging in.

Feb 21, 2009 11:11 AM in response to admach

i dont understand everything i need to enter into the terminal. especially the "/path/to/dir/or/file" and the "/path/to/home" portions.


Assuming you're talking about the command:

scp -P 31415 -r /path/to/file/or/dir username@dynamic.DNS.name:/path/at/home/


It helps if you break down the components:

• scp
• -P 31415
• -r
• /path/to/file/or/dir
• username@dynamic.dns.name:/path/at/home

The first component, scp is simply the command you're executing.
The second component, -P 31415 is a switch to scp telling it to use the port number 31415 instead of the default port 22. You may or may not need to do this depending on how the remote network is setup (some ISPs block port 22 so people run the server on a non-standard port to get around the block)
The third component, -r tells scp to run recursively - that is, if the source file is a directory, copy that directory and all subdirectories to the target. Without this switch scp would only copy the specified item. This switch may or may not be needed depending on whether you're copying a single file or an entire directory.

The last two switches is where all the magic happens. They are the source and the destination specifiers. It's important to realize that scp can either copy files from your local machine to the remote server, or copy files from the remote server down to your machine, so the order of these two is important - if the first item is local and the second is remote then it uploads that file to the server and if the first item is remote and the second is local it downloads the file from the server.

In this case the command is uploading a local file (/path/to/file/or/dir) up to the server.

When you specify the server (either as a source or target) you use the form:

username@host:/path/to/file


The 'username@' part is optional if your account name on the remote server is the same as your login on your local machine (scp will use that username by default), but if your account name on the remote system is different then you specify it here.
The 'host:' part is the hostname or IP address of the server to connect to
The /path/to/file is the path specifier on the remote machine - either the path of the file to download if you're downloading, or the location of where you want the file you're uploading to go if you're uploading.

Therefore, the command:

scp -P 31415 -r /path/to/file/or/dir username@dynamic.DNS.name:/path/at/home/


Can be interpreted as:

"Copy the entire contents of the directory /path/to/file/or/dir on my machine to the server running on port 31415 at 'dynamic.DNS.name'. Log in as user 'username' on that server and store the uploaded item(s) at /path/to/home/ on the remote machine."

also, not sure about the discussion regarding mac account passwords. is that the password i have on my mac? the one i have to enter when i install apps? or is that a password i assign to my server for login? just not sure.


The password you need is your account's password on the remote machine. This has no bearing on any password you have on your local machine (unless, for some reason, you have them set the same, but then it's just coincidence).

Apr 8, 2009 9:42 PM in response to admach

Hi, I'm having a problem getting this to work. Hopefully i'm just missing something simple.

Here's the command i'm using
scp /Users/travisbland88/Downloads/spxcor.tar usr@cycle1.eecs.ku.edu:/users/079/usr/
and i get this error:
/Users/travisbland88/Downloads/spxcor.tar: No such file or directory
My intentions are to copy the spxcor.tar file to the remote location.


I've also tried /Users/spxcor.tar thinking maybe permissions were a problem, but that didn't fix anything.
I've messed around with it a lot, but i'm stumped.
Thanks
Travis

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

setting up an scp or sftp server

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.