linux etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
linux etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

21 Kasım 2014 Cuma

Linux Apache Server SSL Certificate Generation & Import to another apache server

mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
openssl genrsa -des3 -out server-sec.key 4096
openssl req -new -key server-sec.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server-sec.key -out server.crt
openssl rsa -in server-sec.key -out server.key
ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl

Edit "/etc/apache2/sites-available/default-ssl" with nano or your favourite text editor
Edit the SSLCertificateFile and SSLCertificateKeyFile variables to that they reflect your certificate path

<Virtualhost *:443>
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /var/www-ssl/html/
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

End editing

a2enmod ssl

# restart apache server
/etc/init.d/apache2 restart OR service apache2 restart

Our SSL certificate is ready to be imported to another server

openssl s_client -connect IPOFSERVER:443 | tee ANYNAMEYOULIKE
QUIT

nano ANYNAMEYOULIKE and get rid of the junk. Keep only the text between  -----BEGIN CERTIFICATE----- and  -----END CERTIFICATE-----

# taken from madboa
# Make this a sh file and chmod +x in your certificate folder
# Opensuse => /etc/ssl/certs/
#!/bin/sh
#
# usage: certlink.sh filename [filename ...]

for CERTFILE in $*; do
  # make sure file exists and is a valid cert
  test -f "$CERTFILE" || continue
  HASH=$(openssl x509 -noout -hash -in "$CERTFILE")
  test -n "$HASH" || continue

  # use lowest available iterator for symlink
  for ITER in 0 1 2 3 4 5 6 7 8 9; do
    test -f "${HASH}.${ITER}" && continue
    ln -s "$CERTFILE" "${HASH}.${ITER}"
    test -L "${HASH}.${ITER}" && break
  done
done

After that just enter "./certlink.sh ANYNAMEYOULIKE"

now you have SSL communicatin between those servers.

18 Kasım 2014 Salı

Youtube Download mp3 from a linux box

# Download the mp3 file
youtube-dl -citw --extract-audio --audio-format mp3 URL

# Convert the downloaded mp3 file to 128 bit for general purpose mp3 players
mkdir 128
for f in *.mp3 ; do lame --mp3input -b 128 --resample 44.1 "$f" 128/"$f" && rm -rf "$f" && mv "128/$f" "$f" ; done

# Remove mp3 useless information
eyeD3 --remove-comments --remove-lyrics --remove-images --remove-all *.mp3

Find Files and Delete in a linux box

# Command finds files with gz extention recursively from the directory you are in to sub directories. Modify as you like.
find . -type f -name '*.gz' -exec rm -f {} \;

Netcat Remote Bash

    # On ‘server’ side:
    rm -f /tmp/f; mkfifo /tmp/f
    cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f

    #On ‘client’ side:
    nc 127.0.0.1 1234

Sum numbers in a file

awk '{ sum += $1 } END { print sum }' file

Mount NFS Share

showmount -e SERVERIP
mount -t nfs SERVERIP:/SERVERDIR /MOUNTDIR

Scan New SCSI disk on the fly in a physical or virtual linux box without reboot

ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done

OR

echo "- - -" > /sys/class/scsi_host/host0/scan

Ubuntu Repair Missing PGP Keys

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com keynumber

Ubuntu & Derivatives Set Locale

    export LANGUAGE=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    locale-gen en_US.UTF-8
    dpkg-reconfigure locales

MySQL Server Track ABORTED_CONNECTS

    mysqladmin ext | grep Abort
    mysqladmin ext | grep Abort | grep -v 0
    tcpdump -s 1500 -w tcp.out port 3306
    strings tcpdump.out