Pages

Tuesday, May 31, 2011

ssh-keygen instructions for windows (tortise, putty, winscp, etc)

The gist of it is.  

Create a public/private key in linux using ssh-keygen

Move the private key to authorized_keys in the .ssh folder

Move the private key to windows.

Use puttygen to load the existing private key (from linux) and save the private key (in the windows key format).

Use pageant to load the keys.  Then putty, winscp, tortise will use pageant as a key proxy and not more passwords.

http://linux-sxs.org/networking/openssh.putty.html


 


Saturday, May 28, 2011

Commandline to samba mount linux to a windows share

I've had challenges with in the past getting a mount to work.  The following seems to work without any special consideration in the windows share.  This is especially good because it forces the linux folder to use the user and group so not special consideration is required in apache.

NOTE: /sbin/mount.cifs is a linux command, not a custom shell script.

This is mounting a windows shared folder named "project" to "/var/www/html/project".  The files in linux will all be 666 and the folders in linux will all be 777.  You can customize this.

/sbin/mount.cifs //{YOUR WIN IP ADDRESS}/project /var/www/html/project -o 'uid={YOUR LINUX USERNAME},gid=apache,sockopt="TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192",dir_mod=0777,file_mode=0666,noperm'

Put this in a shell script or an alias and it is quick, easy, and reliable.

Sunday, May 15, 2011

Python count files in dirs program; better ls | wc -l (word count)

#!/usr/bin/python

import os
from os.path import join, getsize
for root, dirs, files in os.walk('.'):
    print root, "consumes",
    print sum(getsize(join(root, name)) for name in files),
    print "bytes in", len(files), "non-directory files"