Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A tutorial on using SSH for remote access Network
There was a question in the quickies about accessing files in a Public folder from another SSH capable computer. In this piece, I'll try to answer that question and hopefully help folks understand SSH a little better.

Read the rest of this article for a great overview on what SSH actually is, and how to use it for remote connectivity in OS X.

SSH is really a collection of different pieces. There is a server, sshd, that allows secure connections into your machine, as well as a number of clients for making secure connections to other machines. The ssh client allows you to open a secure shell on a remote machine. We will use scp, which stands for secure copy, to access the Public folder. This article assumes that SSH is already running on your machine. For help getting SSH running on your machine, there is a nice piece at stepwise.

Here is the original question.
I want to be able to get documents from my public folder from any SSH capable computer. How do I go about setting this up? I already have SSH installed, and have enabled remote access and turned on file sharing. Also, I know my SSH port will work. Now what? Do I need to create a guest user in the 'User' pref panel? Keep in mind, all I want is to be able to access my public folder remotely. - anonymous
First off,do not enable remote access or file sharing in the System Prefs. Turning on remote access turns on telnet access to your box. Telnet is not secure. Turning on file sharing turns on ftp access to your box. FTP is not secure. We will only need SSH. Also, there is no need to create a new user. You will login with the same account that owns the public folder.

Let's assume the owner of the Public folder is the user jose, that the Public folder is in it's default location, and you want a file named file.txt. For purposes of the example, we will assume that you are accessing the Public folder from a Unix machine with SSH installed as well.

To connect to your OS X box from the remote UNIX machine, you simply invoke the SSH client at the command line:
ssh -l jose -p
UNIX will come up and ask you for a password, and then you'll be connected to your home box via the command line. You can copy, move, delete, rename, etc. anything that you could normally do as yourself at home. However, those changes all take place on your OS X box, so there's no obvious way to copy a file to your local machine. That's where scp comes into play. NOTE: If you are trying to access the Public folder from a Mac or Windows machine, most good ssh clients have scp included as well. See the documentation for how to use your specific client.

The syntax for scp is pretty simple. scp takes two parameters, where you are copying from and where you are copying to. In UNIX, your current directory is "." (the period, called dot). If you want to copy file.txt to your current location, you would type:
scp .
You should be prompted for the password for jose. After typing in the password, the secure transfer of file.txt should begin.

As with all Unix commands, see the man (manual) pages for more information.
man scp [and] man ssh
Hope this helps,
  • Currently 4.17 / 5
  You rated: 5 / 5 (6 votes cast)

A tutorial on using SSH for remote access | 2 comments | Create New Account
Click here to return to the 'A tutorial on using SSH for remote access' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Thanks, but now what
Authored by: Anonymous on Apr 01, '01 04:37:42PM

Thanks for the tutorial. It has helped me out tremendously. A problem I'm having now is that when I try to scp a file I get this error message: warning: Cannot open source file <host:file>

Any ideas? Do I just not have permission to scp from this particular server?

[ Reply to This | # ]
Re:Thanks, but now what
Authored by: Anonymous on Apr 02, '01 05:09:17AM
I tried different combinations to try to reproduce your error (coming from a Linux machine trying to scp to/from a MacOSX machine), but the best I could come up with is a "No such file or directory" or a "permission denied".

So at most I can suggest two things.

1) try putting a "/" in front of "Users". I couldn't scp without it when I tried. An initial "/" in unix signifies to start from the root directory.
scp jack@ .

2) In the initial example above, make sure you include the final space and ".". This indicates to copy into the existing local directory.

3) If you can't retrieve a remote file, try transferring a local file to the remote MacOSX machine by using scp. just reverse the arguments after scp, i.e.:
scp myfile.txt jack@

Hope this helps. Otherwise I can assure you that it does work, so just keep trying...

[ Reply to This | # ]