linux

ssh authorization

Create a public ssh key, if you haven’t one already. Look at ~/.ssh. If you see a file named id_dsa.pub then you obviously already have a public key. If not, simply create one. ssh-keygen -t dsa ItemMake sure your .ssh dir is 700: chmod 700 ~/.ssh Get your public ssh key on the server you want to login automatically. scp ~/.ssh/id_dsa.pub remoteuser@remoteserver.com: Append the contents of your public key to the ~/.

Self-Signed SSL Certificate

Note: This is a slighltly modified reprint from http://www.akadia.com Overview The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process. Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions.

Log Rotate

Simple: Create following file Change the MAXSIZE & LOGDIR (see file) Add a cron job Create following file: nano /var/www/log/logrotate.sh #!/bin/bash MAXSIZE=1024 LOGDIR=/var/www/log/ if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi cd $LOGDIR for FILENAME in *.log; do SIZE=$(du -b $FILENAME | cut -f 1) if(($SIZE>$MAXSIZE)); then TIMESTAMP=`date +%Y%m%d` NEWFILENAME=$FILENAME.$TIMESTAMP mv $FILENAME $NEWFILENAME touch $FILENAME chown www-data.

Network Safety Restart Bash Script

If you ever work on a remote servers network settings then this script may safe you from having to call support, and waiting on them. When started/executed it Sleeps first for 1 hour Then it renames the ”/etc/network/interfaces” file by adding the current time stamp to the end of the file It renames a file called ”/etc/network/interfaces.org” to ”/etc/network/interfaces” And finally it restarts the server. It also warns you a couple minutes before it does all that so you can terminate the program.

Linux backround process

Running as background process with nohub nohup scp & > nohup.out 2 > &1 nohup scp -r -p root@www.example.com:/var/www/ /var/www/ & >nohup.out 2>&1 nohup scp -r -p root@www.example.com:/var/www/logs /var/www/ & >nohup.out 2>&1

Linux find & replace HowTo

Find and chmod files or folders find . -type d -exec chmod 755 {} ; find . -name "*.php" | xargs grep -niP 'thingy' Find a directory and display on screen find . -type d -name 'linux' 2>/dev/null Find/Grep for a string across multiple files with different extensions find ( -name "*js" -o -name "*jsp" -o -name "*jspf" ) | xargs grep -niP 'thingy'

Netbeans error

I been using Netbeans and following solved the problem: manticore:/etc/sysctl.d# telnet ::ffff:192.168.1.1 Trying ::ffff:192.168.1.1... telnet: Unable to connect to remote host: Network is unreachable manticore:/etc/sysctl.d# sysctl net.ipv6.bindv6only net.ipv6.bindv6only = 1 manticore:/etc/sysctl.d# sysctl net.ipv6.bindv6only=0 net.ipv6.bindv6only = 0 manticore:/etc/sysctl.d# telnet ::ffff:192.168.1.1 Trying ::ffff:192.168.1.1... Connected to ::ffff:192.168.1.1. Escape character is '^]'.