Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Problems with SFTP
PostPosted: Tue Dec 21, 2010 8:23 am 
Offline
Senior Member

Joined: Thu Mar 11, 2010 1:09 pm
Posts: 62
Well, I'm trying to provide SFTP access for another user, I'm following this guide http://library.linode.com/security/sftp-jails/
but something's just not working.

First of all I was geting this error:
"Directive 'UsePAM' is not allowed within a Match block" after trying to execute "/etc/init.d/ssh restart.

I found the solution with putting the Match block at the very end of the config file.

Second, this guide doesn't tell that I need to create a user and how, so I found that here http://library.linode.com/LikRHS

My problem now is this:
when I try to execute the last line of code:

chown username:username *

I get this error:

chown: invalid group: `username:username'

I need to make that a user that I created can go only to /srv/www/exaple.com

Please help, I'm stuck with this for 2 days now...


Top
   
 Post subject:
PostPosted: Tue Dec 21, 2010 8:52 am 
Offline
Senior Member

Joined: Thu Mar 11, 2010 1:09 pm
Posts: 62
Ok, so I've found the solution, on that last line:

chown username:group *

should be, and not username:username *.

This way, I can log in to the site with SFTP, in the right place /srv/www/example.com, BUT user can see all files on the server.

How can I fix that last thing, so that user can see only his files in /srv/www/example.com ?


Top
   
 Post subject:
PostPosted: Tue Dec 21, 2010 1:05 pm 
Offline
Senior Member

Joined: Mon Dec 20, 2010 11:37 pm
Posts: 76
Look at this: http://library.linode.com/security/sftp-jails/


Top
   
 Post subject: Re: Problems with SFTP
PostPosted: Tue Dec 21, 2010 1:14 pm 
Offline
Senior Member

Joined: Thu Mar 11, 2010 1:09 pm
Posts: 62
Thanks, but :)
AndrijaM wrote:
Well, I'm trying to provide SFTP access for another user, I'm following this guide http://library.linode.com/security/sftp-jails/
but something's just not working.

Thats what I'm refering to, but I can't get it to work. Anybody else, anything?


Top
   
 Post subject: Re: Problems with SFTP
PostPosted: Tue Dec 21, 2010 5:41 pm 
Offline
Senior Member

Joined: Mon Dec 20, 2010 11:37 pm
Posts: 76
AndrijaM wrote:
Thanks, but :)
AndrijaM wrote:
Well, I'm trying to provide SFTP access for another user, I'm following this guide http://library.linode.com/security/sftp-jails/
but something's just not working.

Thats what I'm refering to, but I can't get it to work. Anybody else, anything?


Yes, sorry.

I've just tried that setup and it worked for me. I think your jail is not working at all.

Is /var/www/example.com HOME directory for that username? You can check it executing "env" from console with the username rights, and you will see one line "HOME=/your/home/path".

That HOME should be /var/www/example.com. If it isn't, you can edit your user with "usermod -d /var/www/example.com username".


Top
   
 Post subject:
PostPosted: Tue Dec 21, 2010 5:56 pm 
Offline
Senior Member

Joined: Wed Oct 20, 2010 12:11 pm
Posts: 142
Did you add your user to the 'filetranster' group (that you made for the match statement)?


Top
   
 Post subject: Re: Problems with SFTP
PostPosted: Wed Dec 22, 2010 7:06 am 
Offline
Senior Member

Joined: Thu Mar 11, 2010 1:09 pm
Posts: 62
drpks wrote:
Is /var/www/example.com HOME directory for that username? You can check it executing "env" from console with the username rights, and you will see one line "HOME=/your/home/path".


Can you tell me exactly what should I type for env command, what is the correct syntax?

If I type env username
I get no such file or directory

drpks wrote:
That HOME should be /var/www/example.com. If it isn't, you can edit your user with "usermod -d /var/www/example.com username".


When I try usermod -d /var/www/example.com username
I get usermod: no changes, I guess that means that's fine.

As I said, I'm able to login, but the user can see everything else on the server, he can browse to the top, he can't write anywhere else but in his directory example.com, but I need also that he can not see anything else but his own site.


Top
   
 Post subject:
PostPosted: Wed Dec 22, 2010 6:17 pm 
Offline
Senior Member

Joined: Mon Dec 20, 2010 11:37 pm
Posts: 76
Let's say your username is "john"

You have to be logged-in in a console as "john" and type "env" command. "env" shows users environment variables. Alternatively, you can type "echo $HOME". It should return "HOME=/var/www/example.com"
If it isn't, you must change it with "usermod -d /var/www/example.com john"(run as root).

I think you have set up in your SCP/FTP client the remote path to /var/www/example.com... that's why you can login.


Top
   
 Post subject:
PostPosted: Fri Dec 24, 2010 3:23 pm 
Offline
Senior Member

Joined: Thu Mar 11, 2010 1:09 pm
Posts: 62
well - it works now :)

have to say this manual http://library.linode.com/security/sftp-jails/ is not really for beginers, it assumes that you already know something.

And also, there is one big mistake, well I don't know if it's a mistake, but it did not worked for me:

the last line of code in manual:

chown username:username *

is not working for me, I had to change it like this:

chown username:usergroup

and after that all works fine, user can log into his site-directory, and can not see other stuff on server.

@drpks
thanks :)


Top
   
 Post subject:
PostPosted: Fri Dec 24, 2010 8:00 pm 
Offline
Senior Member

Joined: Wed May 13, 2009 1:18 am
Posts: 681
I assume you're not using a Debian-based distribution? They use a group scheme where each user gets a group of the same name as the username so technically it works as written.

Though using something like user:group would be more generic, and still applicable to Debian/Ubuntu (perhaps with a comment that the default group is typically the same as the user).

-- David


Top
   
 Post subject:
PostPosted: Sat Dec 25, 2010 7:12 am 
Offline
Senior Member

Joined: Thu Mar 11, 2010 1:09 pm
Posts: 62
Yes, I'm using Ubuntu, I guess thats what the problem was, it should be there in the manual, how am I supposed to know that?
I was thinking why is this command not working, and I tried username:usergroup and it worked, but I lost about a week on all this...
I will submit a comment there in the manual with link to this thread, I'm sure someone will need this sooner or later :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group