Skip to content

Instantly share code, notes, and snippets.

@eegrok
eegrok / osx-ip-aliases.txt
Created June 1, 2011 18:47
***TODO-FIGURE OUT*** - setup multiple aliases for a single ip on mac osx
# I currently have the following aliases on mac osx, that I use to allow a bunch of different port forwarding through ssh
# the 10.0.2.16 alias appears to work fine without the route add -host call for it
# but the 10.0.2.18 alias doesn't.
# test (order important?)
# test (more than 2?)
# look at netstat -nr to see routes
alias aliasip='sudo ifconfig en1 alias 10.0.2.16 255.255.255.0; sudo ifconfig en1 alias 10.0.2.18 255.255.255.0; sudo route add -host 10.0.2.18 -interface 127.0.0.1'
alias unaliasip='sudo ifconfig en1 -alias 10.0.2.16; sudo route delete -host 10.0.2.18 -interface 127.0.0.1; sudo ifconfig en1 -alias 10.0.2.18'
@eegrok
eegrok / iptables-log-blocked.txt
Created June 9, 2011 22:28
IPTables log a blocked packet
# if you are dropping packets using iptables, you can use a couple commands to log those blocked packets
# for example, to log & block all traffic incoming to 172.25.0.1, you could use the following:
iptables -A INPUT -p tcp -d 172.25.0.1 -j LOG --log-prefix "blocked 172.25.0.1 :"
iptables -A INPUT -p tcp -d 172.25.0.1 -j DROP
@eegrok
eegrok / ssh-x-forwarding.txt
Created June 10, 2011 20:11
forwarding X over ssh
# generally speaking if you run ssh -X <remotehost>
# you'll be able to run X applications on the remote host, displaying them on your machine
# if you need to run them as a different user, there are a couple things you need to setup as the new user
# after su'ing to the new user, you need to:
# (note that the .Xauthority file must be readable by the su'd to user -- or else you need to copy the file somewhere it is readable)
# export XAUTHORITY=/home/[the original user]/.Xauthority
# export DISPLAY=(whatever the DISPLAY property was before you su'd -- probably localhost:10.0)
# the .Xauthority file needs to be readable by the new user as well (when I've done it, I've just copied ~/.Xauthority to /tmp or something for a bit -- of course this means anyone can display on your screen who sees that file -- so caution is a good thing.
@eegrok
eegrok / jconsole-vpn.txt
Created June 14, 2011 21:27
setup jconsole to work through firewall, or over vpn or tunneled ssh
//this method should mostly set up a java app to act as a jconsole server, with static ports so you can configure forwarding through a firewall or over a vpn
public static void setupJConsole(MBeanServer mbs, String hostname, Integer port1, Integer port2) {
// from http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdfvv
// note you need to set the following startup parameters:
// -Dcom.sun.management.jmxremote.authenticate=true
// -Dcom.sun.management.jmxremote.ssl=false
// and this one, if you don't want the rmi server to tell people to connect to the default ip (as is the case if using a vpn ip)
// -Djava.rmi.server.hostname=vpnhostip
// Ensure cryptographically strong random number generator used
// to choose the object number - see java.rmi.server.ObjID
@eegrok
eegrok / no-ssh-password-mac.txt
Created June 23, 2011 21:48
disable password ssh authentication on mac os
make sure the following lines are set in /etc/sshd_config (or /etc/ssh/sshd_config on ubuntu)
(they all exist already, but are commented, some may have a value of yes)
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
then restart the ssh server (uncheck / recheck 'Remote Login' in the 'System Preferences' -> 'Sharing' panel)
@eegrok
eegrok / keyremap4macbook-fix.xml
Created August 15, 2011 21:12
KeyRemap4Macbook custom file to make broken keyboard usable again
<?xml version="1.0"?>
<root>
<item>
<name>Kems custom keybindings</name>
<list>
<item>
<name>Fix broken keyboard</name>
<list>
<item>
<name>Remap broken keys</name>
@eegrok
eegrok / initial-git-config.txt
Created September 16, 2011 22:15
Initial git configuration stuff
git config --global user.name “My Name” (put in your name)
git config --global user.email “[email protected]” (put in your email address)
git config --global branch.autosetuprebase always
git config --global core.excludesfile ~/.gitignore
@eegrok
eegrok / linux-bash-tips.txt
Created November 22, 2011 23:24
uncommon linux / bash commands worth using
you can pipe stuff through ssh -- e.g., concatenate your SSH key on another host.
cat ~/.ssh/id_dsa.pub | ssh me@remotebox "cat >> ~/.ssh/authorized_keys"
lsof - http://danielmiessler.com/study/lsof/
disown (detach from process so when close your terminal it doesn't get killed -- like doing nohup in advance)
xargs / parallel
sudo !! -- repeat last command with sudo prepended
!$ -- last argument to last command
!* -- all arguments to last command
@eegrok
eegrok / php-apache-lion
Created December 8, 2011 22:06
set up php / apache on osx lion
#create file containing something like below -- in /etc/apache2/sites/localweb.conf
# (you may need to create the /etc/apache2/sites directory)
<VirtualHost 127.0.0.1:80>
ServerName www.localweb.com
ServerAlias *.localweb.com
DocumentRoot "/Users/kem/src/localweb"
<Directory "/Users/kem/src/localweb">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
@eegrok
eegrok / osx-lion-samba-server-announce.txt
Created January 1, 2012 03:22
set up auto-announce of samba server on osx lion (since finder / pathfinder don't see samba servers by default atm)
from: http://macw.us/sek9nV
(for more information on creating launch daemons / agents, go to http://j.mp/uYtpsJ )
create a file in ~/Library/LaunchAgents
named something like:
com.yourdomain.smb_server.domain_announce.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">