Note: this is really a how-to, w/o any in-depth explanation, just a note to myself.

Today, I needed to add SSL support to UMapper.com application running on my Slackware localhost. We use CA-signed certificates on our server, but for local box self-signed was quite enough (all I need is to be able to view development version of site via https). Here what I did:

1. Create private key:

$ openssl genrsa -out localhost.key 1024

2. Generate CSR (Certificate Signing Request):

$ openssl req -new -key localhost.key -out localhost.csr

3. Generate certificate:

$ openssl x509 -req -days 365 -in localhost.csr \
        -signkey localhost.key -out localhost.crt

4. Make sure SSL is enabled in httpd.conf:

# Following two should be uncommented
LoadModule ssl_module lib/httpd/modules/mod_ssl.so
Include /etc/httpd/extra/httpd-ssl.conf

5. Edit httpd-ssl.conf so that virtual host users your created certificate:

# locate and edit cert.details. Make sure localhost.crt and localhost.key
# are present (you either created them there or copied)
SSLCertificateFile "/etc/httpd/certs/localhost.crt"
SSLCertificateKeyFile "/etc/httpd/certs/localhost.key"

6. Restart apache:

$ apachectl restart

That’s it. Please note that browser would still generate exception (and it is a good thing, as otherwise certificates wouldn’t be that useful). All you need is to add your localhost as exception – since we really trust that details we provided during certificate creation are our own :)

P.S. If you are getting «[warn] _default_ VirtualHost overlap on port 443,
the first has precedence», add NameVirtualHost *:443 into your httpd.conf

,

Couple of days ago I decided to give lighttpd web-server a try. I didn’t want to uninstall already installed apache, I just wanted it to stop and not auto-start itself on system reboot. Stopping apache is trivial, as it turned out disabling it is even easier:

# aptitude install sysv-rc-conf
# sysv-rc-conf

From there just turn off apache service and press ‘q’ to quit. I really liked this nice command line tool!

,

I am creating custom AMI from very well prepared Ubuntu 9.04 Jaunty (Server) AMI by Eric Hammond. In process, I decided to ship vsftpd (simple and very stable ftp server) by default with my AMI. So, I went on with installing vsftpd:

apt-get install vsftpd

I further configured installed FTP server (/etc/vsftpd.conf):

anonymous_enable=NO # don't want anonymous access
pasv_enable=YES # enable passive mode
pasv_min_port=50000
pasv_max_port=50100
pasv_address=YOUR_INSTANCE_ASSOCIATED_IP
local_enable=YES # enable local users to login into system
write_enable=YES # enable local users to execute FTP write commands

Everything is pretty much simple, probably except for pasv ports. In a nutshell, passive mode means server handles which ports are used for data transfers, and we are using ports in range of 50000-50100. Now any system user should be able to login into your server via ftp. If you need further info regarding laying down the user accounts read my previous post.

One last thing – data ports should be accessible (which is obvious but I have spent half an hour figuring out why I can login via ftp, but cannot execute LIST command), so configure your authorization group accordingly:

ec2-authorize default -p 50000-50100 #open ports for default group

I hope it saves you some time.
Have a nice weekends!

If you need more info on how FTP functions here is good overview.

, , ,

One-liner that I use almost daily when working with source files (put it on separate lines for readablity):


find . -type f -not -regex '.*/.svn/*.*'
-exec grep -Hn --colour 'SEARCH_STRING '{}' \;

You see, when you need to find some string within source files, and you don’t want to see duplicates coming from .svn folders, this one-liner does the trick – .svn directories are ignored from search.

, ,

If you’re like me very fond of Thunderbird (or Firefox, Seamonkey, GQView, Pidgin and similar GTK applications), and are geek enough to run Slackware while being complete novice to Linux – you’ve probably noticed that your GTK look’n'feel is like..well complete crap.

To get rid of this issue, I used to install themes, or for applications other than Thunderbird just got used to their ugly look, but then yesterday I got Ubuntu 8.10 disc and my brother’s notebook. Combined, they demonstrated me one of the best out-of-box distributions, and you know what? GTK applications in there look really nice! That was a moment I realized that my Slackware shouldn’t be left behind (well, it took me only 2 months to figure that out – kudos!). The only thing that was required is to enable Xfce configuration:

$xfce-mcs-manager

Once typed into console, try to re-open one of your GTK2 applications – you should be amazed how ugly previous style was. If you don’t want to initialize Xfce manager manually on every login (and you don’t) you have to make sure that this command is invoked when your window manager launches. For me, I just put the xfce-mcs-manager command into .xsession file (depending on your configuration .xinitrc might also be an option).

Hope that saves you some time, and you’d be smarter than me :)

If you need more similar tips – make sure you read How to properly setup Slackware Linux!

UPD: Checkout xfce-setting-show if you want to manipulate Xfce settings.

,

There’s probably an easier way to do this, but I haven’t found it. I have quite an extensive collection of IT books in PDF format, and not all of them come with navigation bookmarks. On Windows that was not a problem since Adobe Professional allows you to edit pdf documents. It’s only a pity that it doesn’t have a Linux version (it should be noted that Acrobat Reader is available for Linux).

So, when I wanted to edit newly downloaded e-book in pdf format (there were no bookmarks at all!), I scrattched my head, asked google and didn’t find anything suitable. Going a little deeper with the search I located very good program that does exactly what I need – it is able to add/delete/edit bookmarks of existing pdf files.

Program is called JPdfBookmarks, and it works like a charm (it even has a GUI version).

,

Сегодня возникла надобность добавить нового ftp-пользователя используя шелл. На самом деле задача эта достаточно тривиальная, но все-таки поделюсь с теми, кто возможно не знает как это сделать.

Для начала стоит создать нового пользователя, испольуя стандартные средства useradd:

useradd -d /home/ftp/myuser/ -s /dev/null myuser > /dev/null 2>&1

Домашней принята директория /home/ftp/myuser (в общем-то это стандартно), можно естественно использовать любую другую директорию, хотя лучше все же делать не извращаясь.

В большинстве случаев, доступ к шеллу должен быть закрытым для пользователя, поэтому мы использовали флаг «-s /dev/null», т.е. как shell у пользователя будет использована псевдо-оболочка /dev/null. Стоит заметить, что у меня (на CentOS) подключиться через фтп удалось только при использовании /bin/false, /dev/null же перекрывал доступ как к шеллу, так и к фтп. В чем дело разбираться не захотел, возможно именно так это и должно работать на этой дистре (хотя в RedHat изначально добавленна псевдо-оболочка /dev/null в /etc/shells вроде как именно для этих целей).

После создания пользователя, задаем пароль:

passwd myuser

Далее, следует убедиться что /dev/null (в случае с CentOS /bin/false) присутсвуют в /etc/shells. Если наша псевдо-оболочка не найдена, добавляем ее.

И последнее, для удобства пользователя, заходящего через фтп, стоит по-определению открывать именно директорию его аккаунта. Как это сделать? ЛеХко! Для этого редактируем /etc/passwd:
вместо

myuser:x:10010:10010::/home/ftp/myuser/:/bin/false

вставляем

myuser:x:10010:10010::/home/ftp/./myuser/:/bin/false

таким образом при входе в систему, пользователь попадет в каталог myuser.

Вот, в общем-то, и все! Удачного начала рабочей недели.

В случае когда определенные файлы/каталоги не должны попадать под контроль версий, достаточно установить свойство svn:ignore:

svn propset svn:ignore *.pyc dirname

В случае если такое свойство уже существует:

svn propedit svn:ignore dirname

Например, на UMapper‘е для игнорирования авто-сгенеренных CAPTCHA файлов находящихся в каталоге /files/captcha и имеющих названия вида «cap_RANDOM_STRING», я использовал следующую комманду:

svn propset svn:ignore cap_* /files/captcha/
,

Еще кое-что о развертке приложения с использованием svn. Бывает что нужно изменить все файлы или каталоги (а также подкаталоги), скажем сменить permission mask. Это легко сделать используя:

find . [pattern] -exec chmod +x '{}' \;

Однако, в наших каталогах, кроме собственно данных, находяться также системные папки Subversion – .svn, и изменения в них вноситься вручную никак не должны. Чтобы игнорировать все .svn каталоги, используем опцию -prune:

find .  -path '*/.svn' -prune -o -type d -print

Возвратяться все каталоги кроме .svn.

,

Как известно Слака конфигурируется большей частью ручками, редактированием конфигурационных файлов (которые обычно либо plain-text либо в xml формате). А так как всего не упомнишь одной из самых используемых команд является, безусловно, man – то бишь вызов справки. Чтобы немного упростить чтение доков, текст выдаваемый man можно разукрасить, например так:

В ~/.bashrc добавлем следующую строчку:

export PAGER="most"

Все, теперь для постраничного вывода будет использоваться утилита most, попробуйте открыть какую-нибудь man-страничку, теперь ориентироваться по докам чуть проще.

Ну а если вообще красоты захотелось, то Konqueror поддерживает протокол man, попробуйте в адресной cтроке ввести «man:vim», по-моему, лучшего и не надо.

Удачного начала рабочей недели!

,