ceturtdiena, 2013. gada 14. marts

VNC encrypted connection using SSH

Connect to remote host with ssh (assume vncserver is runing on 5901 port)
$ ssh -L 5902:localhost:5901 user@remotehost

Run vncviewer
$ vncviewer localhost:2

For windows using PuTTY
Add forwarded port:
Connection > SSH > Tunnels
Source port: 5902
Destination: localhost:5901
click [Add]
Connect and then run vncviewer localhost:2

sestdiena, 2013. gada 12. janvāris

bash script to send mail via SMTP

Download and install msmtp

Create .msmtprc with following lines:
account default
host smtp.gmail.com
port 587
from me@gmail.com
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
auth on
user me@gmail.com
password gmailpassword
logfile ~/.msmtp

$ chmod 600 ~/.msmtp

$ msmtp -t < somefile

First lines of 'somefile' should be header info such as To:, From:, Subject:.

otrdiena, 2012. gada 13. novembris

KVM on Slackware 14.0

Download from slackbuilds.org following packages and dependencies:

Install all packages the following way:
tar -xvzf pkg.tar.gz
mv pkg-1.0.tar.gz pkg/
installpkg /tmp/pkg-1.0.tgz

* To install yajl, pkg must be renamed:
mv lloyd-yajl-2.0.4-0-gfee1ebe.tar.gz lloyd-yajl-2.0.4-0-fee1ebef.tar.gz

After installation add following lines to /etc/rc.d/rc.local:
/sbin/modprobe kvm
/sbin/modprobe kvm_intel
libvirtd -f /etc/libvirt/libvirtd.conf -d

Start just added lines from rc.local and run virt-manager

* If virt-manager displays an error on startup about D-BUS, try this command:

* Optional: create bridge

Network Bridge on Slackware

Add following lines to /etc/rc.d/rc.local:

ifconfig eth0 inet
ifconfig eth0 up
brctl addbr br0
brctl addif br0 eth0
dhcpcd br0

trešdiena, 2012. gada 1. augusts

ceturtdiena, 2012. gada 29. marts

WebDAV with Apache on Slackware 13.37

Edit httpd.conf, uncomment:
Include /etc/httpd/extra/httpd-dav.conf
at the end of file add:
DAVLockDB /var/www/DAVLock.db
DAVMinTimeout 600

# touch /var/www/DAVLock.db
# chown apache:apache /var/www/DAVLock.db

Create virtual host in /etc/httpd/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot "/var/www/htdocs"
ServerName example
ServerAlias www.example.com
<Directory "/var/www/htdocs">
Allow from all

# WebDav config part
Alias /webdav /var/www/htdocs
<Location "/webdav">
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/htdocs/passwd.dav
Require valid-user
# End of WebDav config
ErrorLog "/var/log/httpd/example.com-error"
CustomLog "/var/log/httpd/example.com-custom" common

Create password file:
# htpasswd -c /var/www/htdocs/passwd.dav test
# chown root:apache /var/www/htdocs/passwd.dav
# chmod 640 /var/www/htdocs/passwd.dav

Restart apache web server:
# /etc/rc.d/rc.httpd restart

pirmdiena, 2012. gada 30. janvāris

Tor exit relay on linux

We will run tor as a regular non-root user on slackware 13.37.
First download and install libevent:
tar -xvzf libevent-2xxx
cd libevent-2xxx
make install

Download tor source code and install:
tar -xvzf tor-0xxx
cd tor-0xxx
./configur --with-libevent-dir=/usr/local/lib
make install

Create configuration files:
cd /usr/local/etc/tor
cp torrc.sample torrc
mkdir /var/log/tor
touch /var/log/tor/notices.log
touch /var/log/tor/debug.log
mkdir /var/run/tor
touch /var/run/tor/tor.pid
mkdir /var/lib/tor

chown -R user:users /var/log/tor
chown -R user:users /var/run/tor
chown -R user:users /var/lib/tor

Edit torrc:
SocksPort 9050
DirPort 9030
Log notice file /var/log/tor/notices.log
# Log debug file /var/log/tor/debug.log
DataDirectory /var/lib/tor
Nickname mynickname
ContactInfo your name <mail AT mail dot com>
ORPort 9001
# 443
RelayBandwidthBurst 100 KB
# 800Kbps
RelayBandwidthRate 200 KB
# 1600Kbps

Test run:
/usr/local/bin/tor -f /usr/local/etc/tor/torrc

Edit and set up control script located in source directory:
vim tor-0xxx/contrib/torctl

cp torctl /usr/local/bin/scripts/
chmod +x /usr/local/bin/scripts/torctl

Edit tor.sh:
#export TORUSER

cp tor.sh /etc/rc.d/init.d/tor.sh
chmod +x /etc/rc.d/init.d/tor.sh

Options: start | stop | restart | reload | status

Your are done!
/etc/rc.d/init.d/tor.sh start

*Running tor as root is not recommended.