Hi I'm trying to create a user that has only sftp access to my server and no ssh access. These are the commands I use:
cd /home/
adduser [SFTP USER NAME]
usermod -G sftp [SFTP USER NAME]
usermod -s /bin/false [SFTP USER NAME]
chown root:root /home/[SFTP USER NAME]
chmod 0755 /home/[SFTP USER NAME]
# usermod -d [SFTP USER FOLDER] [SFTP USER NAME]
/etc/init.d/ssh restart
# now add a folder the user can write into
mkdir home/[SFTP USER NAME/FOLDER]/private
# give permissions
chown [SFTP USER NAME]:[SFTP USER NAME] /home/[SFTP USER FOLDER]/private
and in my /etc/ssh/sshd_config I have a sftp group that has the right settings. Like in this guide.
Also I need to say that it already worked for other users.
I think I have some error in my documentation. Can somebody please have a look and tell me if something is missing or wrong.
Thanks
Hm. I had a look into my bash history and it works like this:
cd /home/
adduser [SFTP USER NAME]
usermod -G sftp [SFTP USER NAME]
usermod -s /bin/false [SFTP USER NAME]
chown root:root [SFTP USER NAME]
chmod 0755 [SFTP USER NAME]
usermod -d [SFTP USER NAME/FOLDER] [SFTP USER NAME]
/etc/init.d/ssh restart
mkdir [SFTP USER NAME]/private
chown [SFTP USER NAME]:[SFTP USER NAME] [SFTP USER NAME]/private
I think the only difference is the usermod -d thing where I used instead of the full path to the folder the relative path.
Related
I have a Dockerfile on Ubuntu server where I create a user on group www-data with root privileges.
RUN useradd -G www-data,root -u userid (like 1000) -d /home/user (like www) user
RUN mkdir -p /home/user/.composer &&
chown -R user:user /home/user
How I can do the same in alpine linux ?
Hi I added a user using useradd command so that he have no home directory:
useradd -M -u 1110 brinst
Then I wanted too add a home directory for the same user using usermod but that didn't work out:
usermod -m -d /home/lagha brinst
usermod: no changes
How can I create a home directory with all it's folders and hidden files for this user when he doesn't have an old one? - that seems to be easy but somehow it's not working.
mkdir /home/brinst
usermod -d /home/brinst brinst
More cleaner way:
mkhomedir_helper brinst
create user with command like
sudo useradd my-new-user -m -d /home/my-new-user
I am unable to create a directory using sudo priveleges from root user and If I login to user , I can create an directory under /root using sudo. Also I have added to allow all commands in /etc/sudoers file and the details are below:
[root#linux home]# cat /etc/sudoers | grep tes
test ALL= NOPASSWD: ALL
Error
[root#linux home]# sudo -u test mkdir /var/log/test3
mkdir: cannot create directory ‘/var/log/test3’: Permission denied
Any Ideas ?
Thanks
By running 'sudo -u test', you're giving yourself lower privileges than the roor user because you're running the command as the user 'test', not 'root'. From the root user, you can just run:
mkdir /var/log/test3
Read man sudo for more info.
Or:
Run visudo and uncomment the wheel group, then add the user test to the wheel group.
If you don't mind me asking, why do you need to create a directory as a certain user from the root user? Especially since the directory you're making will not be user specific?
Also, in the sudoers file , you should what added test ALL=(ALL) NOPASSWD: ALL, not test ALL= NOPASSWD: ALL
I have created group (lets call this user admin):
sudo groupadd mygroup
switched to user test (from admin user):
sudo su - test
cd /home/test/
mkdir external
exit
cd /home/test/
sudo chgrp -R mygroup external
sudo usermod -a -G mygroup admin
sudo usermod -a -G mygroup test
sudo chmod -R g=rwx external
Now I do this:
cd external
mkdir something
mkdir: cannot create directory ‘something’: Permission denied
So how can I make that everyone that has mygroup would have all access like the owner does? So I could create inside external directory any other directory or file, delete it and so on (without using sudo).
P.S.
ls -l:
drwxrwxr-x 2 test mygroup 4096 Spa 15 16:24 external
getent group mygroup:
ambulance:x:1002:admin,test
sudo groupadd mygroup
mkdir external
sudo chown -R root:mygroup external
sudo chmod -R 'g+w' external
sudo chmod -R 'g+s' external
Hi I have ssh connection to my server wit root account. I want to create user named pizza4yu and give access with winscp to only this location /home/pi/apache-tomcat-7.0.35 How can I do that ?
chsh -s /bin/bash pizza4yu
usermod -d /home/pi/apache-tomcat pizza4yu
chown -R pizza4yu:pizza4yu /home/pi/apache-tomcat
You can also use chroot: http://chrootssh.sourceforge.net/
Set the users home folder to that path so.
Usermod -d /home/pi/apache-tomcat pizza4yu
All in lowercase
Then chown -R pizza4yu /new/path or add the new user to existing group of that folder