Evan’s posterous

Adventures in pomodoro and other such things 
Filed under

linux

 

5 lines every sshd config should contain

to begin to properly secure your linux computer with ssh your sshd configuration file should contain the lines below.  These lines prevent root access, force public key authentication (no password to crack) and restrict access to named users only.

PermitRootLogin no
PasswordAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes
AllowUsers babyman evan

Filed under  //   linux   ssh  

Comments [0]

find every file modified between to dates

the following will find every file changed between 2 timestamps
touch temp -t 200910011130
touch ntemp -t 200910011630
find / -cnewer temp -and ! -cnewer ntemp

Filed under  //   linux  

Comments [0]

verifying a computers listening ports using nmap

one of the most reliable ways to determine which ports are accessible on a computer is to use nmap

nmap -sT -O localhost

alternately

netstat -an
lsof -i

but since these commands do not connect to the actual computer ports they are less reliable

Filed under  //   linux  

Comments [0]

show installed packages using rpm

the following command will sort and show all of the rpm packages installed on a computer using less

rpm -qa | sort | less

Filed under  //   linux   rpm  

Comments [0]

nmap

ever wonder what the IP address of that server in the corner is, you could always try scanning your network for computers using nmap.

sudo apt-get install nmap

to scan for running computers, here using sudo is optional but will provide more information, all others require root privileges

<sudo> nmap -sP 192.168.1.1/24

to scan for open ports on a computer

sudo nmap -sS 192.168.1.1/24

to include open ports and operating system information

sudo nmap -O 192.168.1.1/24

Filed under  //   linux  

Comments [0]

spotlight on linux

if you use a mac and have made spotlight part of your workflow GNOME + Do (http://do.davebsd.com/) is really worth a look

Filed under  //   cool app   linux  

Comments [0]

simple bash script template to process a file

#!/bin/bash
 
if [[ "$#" == 1 && -f $1 ]];
then
 # replace with something functional like 'rm -f $1'!
 echo "file $1 exists"
else
 echo "Usage: $0 "
fi

Filed under  //   bash   linux   script   template  

Comments [0]

copying files with rsync

rsync is a great way to copy files between computers as it can continue after partial copies and update directories when only a few files have changed, it also supports secure file copies over ssh as shown below:

copy files locally:

rsync -rtvzP --delete --exclude=.Trash /Users/evan/ /Volumes/backup/evan/

copy local files to a remote computer excluding all the mac .DS_Store folders in the path:

rsync -ravzP --exclude=**/.DS_Store -e ssh "/Users/evan/my files/" evan@someserver.codepit.ca:/home/evan/files/

copy remote files onto a local computer:

rsync -ravzP -e ssh 10.10.238.123:"/home/evan/my files/" /Users/evan/files/

NOTE the use of " when there is are spaces in the file paths

Useful switches:

-n == dry run, very useful with --delete :o
--delete == delete files when they are missing from the source computer and present on the target

Filed under  //   linux   mac  

Comments [0]

installing trac

Installing the trac (http://trac.edgewall.org/) project to manage bugs and possibly even features/specifications for your projects. First install the trac dependencies

apt-get install python python-central python-setuptools 
python-pysqlite2 python-subversion libjs-jquery python-genshi 
python-tz python-pygments

use easy_install to install the latest version of trac (we had issues with the apt-get version and attachments)

easy_install -n http://svn.edgewall.org/repos/trac/tags/trac-0.11.4

create the directories that will contain our trac project files

mkdir /opt/trac 
mkdir -p /opt/trac/.trac-base/egg-cache 
cd /opt/trac

create the trac project

trac-admin trac-example initenv

create a password file and setup initial users

htpasswd /opt/htpasswd

make sure apache owns the trac directories

chown -R www-data:www-data /opt/trac

configure apache to handle trac as the root site

vim /opt/apache2/sites-enabled/trac

<VirtualHost *:80>
        Alias /trac/ /usr/share/trac/htdocs 
 
        ErrorLog /var/log/apache2/error.trac.log 
        CustomLog /var/log/apache2/access.trac.log combined 
 
         <Location "/">
                SetHandler mod_python 
                PythonInterpreter main_interpreter 
                PythonHandler trac.web.modpython_frontend 
                PythonOption TracEnvParentDir /opt/trac/ 
                PythonOption TracUriRoot / 
                PythonOption PYTHON_EGG_CACHE /opt/trac/.trac-base/egg-cache 
         </Location>

        # use the following for one authorization for all projects 
        # (names containing "-" are not detected): 
         <Location "/">
            AuthType Basic 
            AuthName "trac" 
            AuthUserFile /opt/htpasswd 
            Require valid-user 

        </Location>

</VirtualHost>

restart apache

/etc/init.d/apache2 restart

check the system with your browser by navigating to http://localhost/

 

Filed under  //   apache   linux   trac  

Comments [0]

keyboard and mouse sharing with synergy

So I don't have a dedicated keyboard for my mythtv and I hate to connect one for those little maintenance operations, one solution is to use http://synergy2.sourceforge.net/. Heres how I set it up on my dell mini9 and mythtv server;

install synergy on both systems:

sudo apt-get install synergy

edit the host file and ensure both computers can find each other: 

sudo vim /etc/hosts 

on the laptop something like this:

xxx.xxx.xxx.xxx myth

and on the mythtv server something like this: 

xxx.xxx.xxx.xxx mini9 

create a synergy configuration file on the laptop: 

sudo vim /etc/synergy.config 

section: screens
 mini9:
 myth:
end
section: links
 mini9:
  right = myth
 myth:
  left = mini9
end

start the server on the laptop (-f keeps the server in the foreground for logging/testing purposes):

synergys -f

now start the client end on the mythtv system (also in foreground mode):

synergyc -f mini9

make sure the 2 systems can communicate and that the mouse pointer can move from one system to the other. Set the synergy client to start when the mythtv user logs in: 

go to system -> preferences -> sessions in X and add a new command to run on login:

synergyc mini9

restart the mythtv server and make sure everything starts up correctly, now when you need to access your mythtv system using a mouse and keyboard you can do so from the comfort of your couch my starting the "synergys" server on your laptop.

Filed under  //   linux   mythtv  

Comments [0]