© 2023 PodTECH IO
All rights reserved.

Get in Touch

UNIX

Linux – if anyone logs in notify SSH

Put the following in /etc/profile: The script /etc/profile is executed at every login (for bash shell users).   if [ -n “$SSH_CLIENT” ]; then TEXT=”$(date): ssh login to ${USER}@$(hostname -f)” TEXT=”$TEXT from $(echo $SSH_CLIENT|awk ‘{print $1}’)” echo $TEXT|mail -s “ssh login” you@your.domain aFrom:youradd@email.com fi   If you have issues delivering mail to a GMAIL inbox, […]

Miscellaneous

Add Parameter to URL – JQUERY

Add Parameter to URL – JQUERY function addOrUpdateUrlParam(name, value) { var href = window.location.href; var regex = new RegExp(“[&\\?]” + name + “=”); if(regex.test(href)) { regex = new RegExp(“([&\\?])” + name + “=\\d+”); window.location.href = href.replace(regex, “$1” + name + “=” + value); } else { if(href.indexOf(“?”) > -1) window.location.href = href + “&” + […]

MYSQL

MYSQL Dump Single Table

Dumping Single MYSQL Table mysqldump db_name table_name > table_name.sql mysqldump -u -h -p db_name table_name > table_name.sql mysqldump -u -h -p db_name table_name –events –triggers –routines > table_name.sql    

Miscellaneous

Useful Net::SSH2 commands

#!/usr/bin/perl use warnings; use strict; use Net::SSH2; use Data::Dumper; # see maillist archives at # http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users my $ssh2 = Net::SSH2->new(); $ssh2->connect(‘localhost’) or die “Unable to connect Host $@ \n”; #this works for passwords #$ssh2->auth_password(‘z’,’ztester’) or die “Unable to login $@ \n”; #do key authorization like commandline shell # ssh -o PreferredAuthentications=publickey localhost # See: http://cfm.gs.washington.edu/security/ssh/client-pkauth/ […]

Miscellaneous

Debian Install Packages behind Firewall

Debian Install Packages behind Firewall apt-get –print-uris install mysql-server -y Will print out the URL for the package and dependancies; ‘http://mirrordirector.raspbian.org/raspbian/pool/main/liba/libaio/libaio1_0.3.109-3_armhf.deb’ libaio1_0.3.109-3_armhf.deb 8944 MD5Sum:ddc43710db3f102df9477a8a95f025ad ‘http://mirrordirector.raspbian.org/raspbian/pool/main/m/mysql-5.5/mysql-server-core-5.5_5.5.40-0+wheezy1_armhf.deb’ mysql-server-core-5.5_5.5.40-0+wheezy1_armhf.deb 3060608 MD5Sum:9a8f4620799fcceb4567433caad2434e ‘http://mirrordirector.raspbian.org/raspbian/pool/main/m/mysql-5.5/mysql-server-5.5_5.5.40-0+wheezy1_armhf.deb’ mysql-server-5.5_5.5.40-0+wheezy1_armhf.deb 1729934 MD5Sum:98fe33dd64039ba120d1aa77e0992fa7 ‘http://mirrordirector.raspbian.org/raspbian/pool/main/h/heirloom-mailx/heirloom-mailx_12.5-2+deb7u1_armhf.deb’ heirloom-mailx_12.5-2+deb7u1_armhf.deb 253508 MD5Sum:6155feba05b677f5f01eb5b53ae4ba2d ‘http://mirrordirector.raspbian.org/raspbian/pool/main/libh/libhtml-template-perl/libhtml-template-perl_2.91-1_all.deb’ libhtml-template-perl_2.91-1_all.deb 72020 MD5Sum:b25cc0a02e43fe4b5b46a01af3e98c4c ‘http://mirrordirector.raspbian.org/raspbian/pool/main/m/mysql-5.5/mysql-server_5.5.40-0+wheezy1_all.deb’ mysql-server_5.5.40-0+wheezy1_all.deb 73872 MD5Sum:b49873c3a32d33f6186e779202f6a87e   Cut out the URLs and put them into a file. […]

Miscellaneous

Quick – Install Package on a Firewalled Server

On the firewalled/vpnd server; 1. find the package URL apt-get –print-uris install dos2unix 2. wget over ssh from an internet bound server on the same network ssh use@somehost ‘wget -O – http://mirrordirector.raspbian.org/raspbian/pool/main/d/dos2unix/dos2unix_6.0-1_armhf.deb’ >> dos2unix_6.0-1_armhf.deb 3. dpkg -i dos2unix_6.0-1_armhf.deb

Perl

Perl – Sending Email with NET::SMTP using username and password

Perl – Sending Email with NET::SMTP using username and password First of all double check that Authen::SASL is an installed module.. If you are not getting emails this could be why – it doesnt provide an error that is understandable! #!/usr/bin/perl ### ENSURE Authen::SASL is installed use Net::SMTP; use strict; use warnings; my $host= ‘yourhostname’; […]

UNIX

Fix Open Postfix Relay – Unauthenticated Email

If your mail server is left open, anyone can use your SMTP service to send mail, and spammers will use it. This can result in your server being blacklisted and extraneous use of system resources that neither benefit you nor your users. Postfix logoTo secure Postfix, there are a number of functions you can add […]