Tuesday, November 5, 2013

Limiting sftp accounts with chroot

from http://www.techrepublic.com/blog/linux-and-open-source/chroot-users-with-openssh-an-easier-way-to-confine-users-to-their-home-directories/

#In the file /etc/ssh/sshd_config  :
#make sure the sftp subservice is defined with the line (only once)
Subsystem sftp /usr/lib/openssh/sftp-server

# add the following lines (only once)
Match Group sftp
    ChrootDirectory %h
    ForceCommand internal-sftp
    AllowTcpForwarding no

#Then on the linux shell, create the sftp group (only once)
sudo addgroup sftp

#Create the user and set its properties (for each sftp user)
sudo adduser joe
sudo usermod -G sftp joe
sudo usermod -s /bin/false joe
sudo chown root:root /home/joe
sudo chmod 0755 /home/joe
sudo usermod -G sftp joe
sudo mkdir /home/joe/Data
sudo chown -R joe:joe /home/joe/Data

The usermod command above will add user joe to the sftp group and set their shell to /bin/false so they absolutely cannot ever get shell access. The chown and chmod commands will set the required permissions for the directory. With these permissions set, the user will be allowed to upload and download files, but cannot create directories or files in the root directory. In other words, if this is used for Web hosting, ensure that a subdirectory in the root directory, such as /home/joe/public_html/ is available and owned by the user; this way they can write to and create directories in /home/joe/public_html/, but cannot make changes to the root directory (/home/joe), itself.

Monday, November 4, 2013

Disabling ProFTP service under Parralels PLESK


Edit the file /etc/xinetd.d/ftp_psa and set

        disable         = yes

Note that the process will have to repeated when PLESK will be upgraded :(

Disabling openssh/sftp service

Edit and comment out the line :

Subsystem sftp /usr/lib/openssh/sftp-server

and restart the openssh server

sudo restart ssh (or sudo /etc/init.d/ssh restart)










Wednesday, May 29, 2013

Pushing/pulling a specific branch between local and remote repository

from http://www.mariopareja.com/blog/archive/2010/01/11/how-to-push-a-new-local-branch-to-a-remote.aspx

git push -u origin plugin
 
This tells git to push changes from your plugin branch to the plugin branch on the origin repository. If origin does not have a plugin branch, it is created on the fly. The -u tells git that you want to be able to easily push and pull changes to that branch in the future.

 To perform the opposite, to pull a repo other than master,  use:

git checkout -b experimental origin/experimental

Monday, May 20, 2013

Selective recursive file input for tar archive creation :

find . -name \*L2.dat |tar -czvf file.tgz --files-from -

Saturday, November 24, 2012

Tuesday, October 2, 2012

.htaccess redirect

To redirect from abc.com to blog.abc.com, create a .htaccess  at the root directory of abc.com with the following line in it :

Redirect /index.html http://blog.abc.com