Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I'm trying to do is set up a SSH key that only gives access to certain directories, for security reasons I don't want it to have full access to my SSH server. I already have the ability to access the directories I need over my local network (right now using SMB, although I also used UPnP for awhile). I need, however, to be able to access those files securely over the internet from both Ubuntu and Windows machines.
I'm somewhat new to SSH and not sure what the best approach to solving my problem is. If anyone knows how I can do this or where I can find a detailed tutorial I'd be grateful.

And as always if anything is confusing or if there are any comments or corrections please let me know.

share|improve this question
up vote 3 down vote accepted

My suggestion would be Change Root using ssh. This is a new feature of the OpenSSH server since version 4.8p1. (ubuntu package: openssh-server) and hence available on the newer ubuntu releases.

In a nutshell, if a certain user (for which you would distribute the key) logs in via ssh, he/she will be jailed inside a named directory making access to anything that's outside of that inaccessible. This is particularly straightforward to set up if you only want access to files and not really run any programs for the chrooted user. See for instance here:

If you can elaborate on the specific needs that you have we can maybe comment more.

Also, once you have your jailed ssh user configured, you might want to consider sshfs (for ubuntu) and netdrive - (for windows) to seamlessly mount these directories on the respective machines.

share|improve this answer
this looks great thanks for the help. – Michael Chapman Feb 19 '11 at 23:43
little caveat: while I use, like and recommend sshfs, I have not tried netdrive - so this came from a google search – DrSAR Feb 20 '11 at 5:27

Your Answer


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.