Skip to main content

Setting up SFTP server in Linux Ubuntu. Command line instructions

Simple step-by-step command line instructions on setting up SFTP server in Ubuntu 12.04, based on http://www.thegeekstuff.com/2012/03/chroot-sftp-setup/ article.

1. Add 'sftpusers' group:

sudo groupadd sftpusers

2. Create a home directory for 'guestuser' user that will be added at the next step:

sudo mkdir /var/guestuserhomedir
As the result of the above command permissions for /var/guestuserhomedir should be 755 (owner: root, group: root).

3. Create 'guestuser' user, add it to the 'sftpusers' group and set a new password for this user:

sudo useradd -g sftpusers -d /var/guestuserhomedir -s /usr/sbin/nologin guestuser
sudo passwd guestuser

4. Create SFTP directories and set permissions (correct permissions are important):

sudo mkdir /var/sftp_upload_dir
sudo mkdir /var/sftp_upload_dir/guestuser
sudo mkdir /var/sftp_upload_dir/guestuser/incoming
sudo chown guestuser:sftpusers /var/sftp_upload_dir/guestuser/incoming
sudo chmod 777 /var/sftp_upload_dir/guestuser/incoming
As the result permissions for /var/sftp_upload_dir and /var/sftp_upload_dir/guestuser directories should be 755 (owner: root, group: root), permissions for /var/sftp_upload_dir/guestuser/incoming should be 777 (owner: guestuser, group: sftpusers).

5. Open /etc/ssh/sshd_config file and comment out the following line:

# Subsystem       sftp    /usr/libexec/openssh/sftp-server
Now add the new line after the commented out line:
Subsystem       sftp    internal-sftp
Add the following lines at the bottom of the file:
Match group sftpusers
ChrootDirectory /var/sftp_upload_dir/%u
ForceCommand internal-sftp

6. Restart SSH service:

sudo /etc/init.d/ssh restart

7. Now you can connect to SFTP server using any client of your choice (FileZilla, Midnight Commander), using the username 'guestuser' and password that you have set at step 3. You will have to use the same port as for SSH (22 by default). You will have full access to incoming directory on the server.

Popular posts from this blog

Switching between keyboard layouts in Openbox (Arch Linux)

Switching between two (or more) keyboard layouts in Openbox DE is a task that's quite easy to accomplish, although it might not be so obvious as in other desktop environments. This solution was tested on Arch Linux. You just need to edit this file (assuming you want to switch between English and Ukrainian Phonetic layouts with Alt-Shift): /etc/X11/xorg.conf.d/01-keyboard-layout.conf Section "InputClass" Identifier "keyboard-layout" Driver "evdev" MatchIsKeyboard "yes" Option "XkbLayout" "us,ua(phonetic)" Option "XkbModel" "pc105" Option "XkbOptions" "grp:alt_shift_toggle" EndSection If you have Nvidia card, don't forget to edit /etc/X11/xorg.conf.d/20-nvidia.conf and change Driver from "kbd" to "evdev" in InputDevice section: Section "InputDevice" Identifier "Keyboard0" Driver "evdev" EndSection Y...

How to run Jekyll server on Cloud9

So you already have your Cloud9 account and your Jekyll site is in your workspace. Now you want to run the server. It is actually very simple. In a fresh Could9 workspace you only need to execute the following two commands in the terminal window: gem install jekyll jekyll serve --host 0.0.0.0 --port 8080 After executing these two commands you can open your site in the browser using the following link: https://[workspacename]-c9-[username].c9.io Important note: Only port 8080 works for me in Cloud9, other ports are closed. Also assigning host to 0.0.0.0 is necessary.

Integrating TestRail and Gitlab CI/CD

Perhaps you are using Gitlab CI/CD at your project. Every project requires some test cases for regression testing, and Gitlab actually provides this feature, but it’s only available in Ultimate version that is more expensive. TestRail is another popular platform for managing your test suite that provides way more extensive capabilities and options than Gitlab’s own test case management feature. So the chances are that you are still willing to use TestRail for your acceptance and regression testing efforts. Why not combining the best of two worlds — the flexibility of Gitlab CI/CD and rich test case management capabilities of TestRail? In the following example I’ll demonstrate how this goal could be achieved with ease. Let’s assume that we need to create a new Milestone in TestRail that contains two test runs — the one with Acceptance tests, and another one with Regression tests. The step in your .gitlab-ci.yml Gitlab configuration file would look like this: This step is reading C...