rowty.net code snippets Public source code sharing repository https://rowty.net Force ipv4 or ipv6 on ssh connection - rowty.net code snippets # Forcing ipv4 ssh -4 rowty.net #Forcing ipv6 ssh -6 rowty.net https://rowty.net/view/118/1/Force-ipv4-or-ipv6-on-ssh-connection https://rowty.net/view/118/1/Force-ipv4-or-ipv6-on-ssh-connection Fri, 11 May 2018 11:04:53 GMT Testing open proxy with curl - rowty.net code snippets # Testing w/o username/pass (open proxy) # Replace xxx.xxx.xxx.xxx with your proxy server curl -x http://xxx.xxx.xxx.xxx:8080 http://rowty.net https://rowty.net/view/117/1/Testing-open-proxy-with-curl https://rowty.net/view/117/1/Testing-open-proxy-with-curl Wed, 25 Apr 2018 11:36:53 GMT TCP Traceroute with regular traceroute command - rowty.net code snippets # This will perform a tcp traceroute to port 3306 on rowty.net traceroute -T -p 3306 rowty.net https://rowty.net/view/116/1/TCP-Traceroute-with-regular-traceroute-command https://rowty.net/view/116/1/TCP-Traceroute-with-regular-traceroute-command Mon, 23 Apr 2018 10:30:10 GMT Renew UCS self signed ssl certificate - rowty.net code snippets # ssh into your primary switch ad admin, then: server-b # scope security server-b /security # scope keyring default server-b /security/keyring # set regenerate yes server-b /security/keyring* # commit-buffer # You may need to re-login here on any GUIs you have open.. give it a few... https://rowty.net/view/115/1/Renew-UCS-self-signed-ssl-certificate- https://rowty.net/view/115/1/Renew-UCS-self-signed-ssl-certificate- Thu, 19 Apr 2018 08:06:22 GMT Use SSH in batch mode if hitting multiple servers - rowty.net code snippets # SSH as user root to multiple rowty.net servers.. # The list of servers host1.rowty.net host2.rowty.net host3.rowty.net # Run a command on all of them - using batchmode and timeout for m in $(cat ./rowty-servers.txt);do ssh -o BatchMode=yes -o ConnectTimeout=1 root@rowty.net... https://rowty.net/view/114/1/Use-SSH-in-batch-mode-if-hitting-multiple-servers https://rowty.net/view/114/1/Use-SSH-in-batch-mode-if-hitting-multiple-servers Thu, 1 Mar 2018 15:08:49 GMT Create stronger SSH keys - rowty.net code snippets # Create a 4096 bit ssh key named my_key ssh-keygen -f ~/.ssh/my_key -t rsa -b 4096 # Create an Ed25519 key named my_ed_key (may not work on older machines) # With ssh-keygen use the -o option for the new RFC4716 key format and the use of a modern key derivation function powered by #... https://rowty.net/view/113/1/Create-stronger-SSH-keys https://rowty.net/view/113/1/Create-stronger-SSH-keys Thu, 1 Mar 2018 11:53:25 GMT Display lines in a file after a particular line number - rowty.net code snippets awk 'BEGIN{lineno=3} {if( NR >= lineno) { print }}' gp 3 4 5 6 7 8 9 https://rowty.net/view/112/4/Display-lines-in-a-file-after-a-particular-line-number https://rowty.net/view/112/4/Display-lines-in-a-file-after-a-particular-line-number Fri, 23 Feb 2018 09:48:23 GMT Grep command to display line containing the variable along with lines before and after options - rowty.net code snippets cat gp | grep -A 3 -B 2 5 3 4 5 6 7 8 https://rowty.net/view/111/4/Grep-command-to-display-line-containing-the-variable-along-with-lines-before-and-after-options https://rowty.net/view/111/4/Grep-command-to-display-line-containing-the-variable-along-with-lines-before-and-after-options Wed, 21 Feb 2018 15:16:03 GMT Egrep for number range - rowty.net code snippets cat | egrep [0][1-5] https://rowty.net/view/110/4/Egrep-for-number-range https://rowty.net/view/110/4/Egrep-for-number-range Mon, 19 Feb 2018 15:09:36 GMT RedHat / CentOS remove all old kernels keep 2 - rowty.net code snippets # Change the number at the end package-cleanup --oldkernels --count=2 https://rowty.net/view/109/1/RedHat---CentOS-remove-all-old-kernels-keep-2 https://rowty.net/view/109/1/RedHat---CentOS-remove-all-old-kernels-keep-2 Tue, 9 Jan 2018 10:53:34 GMT gpg not asking for passphrase / password on decrypt - rowty.net code snippets # Make gpg forget your passphrase in its cache - reloading the gpg agent echo RELOADAGENT | gpg-connect-agent # A more permanent option... # create / edit ~/.gnupg/gpg-agent.conf and add the following line so it will never cache: max-cache-ttl 0 https://rowty.net/view/108/1/gpg-not-asking-for-passphrase---password-on-decrypt https://rowty.net/view/108/1/gpg-not-asking-for-passphrase---password-on-decrypt Sat, 16 Dec 2017 14:18:47 GMT Increase scsi timeouts in Linux - rowty.net code snippets # First, check your current settings and jot them down somewhere: for a in /sys/class/scsi_generic/*/device/timeout; do echo -n "$a "; cat "$a" ; done; # Here's how to increase the timeout across all devices to 180 seconds: for i in... https://rowty.net/view/107/1/Increase-scsi-timeouts-in-Linux https://rowty.net/view/107/1/Increase-scsi-timeouts-in-Linux Wed, 13 Dec 2017 10:17:43 GMT Generate ADU report for HP / HPE support - rowty.net code snippets # If it is HPESSACLI hpssacli ctrl all diag file=/tmp/adureport.zip ris=on xml=on zip=on # If it IS HPacucli hpacucli ctrl all diag file=/tmp/adureport.zip ris=on xml=on zip=on https://rowty.net/view/106/1/Generate-ADU-report-for-HP---HPE-support https://rowty.net/view/106/1/Generate-ADU-report-for-HP---HPE-support Tue, 12 Dec 2017 13:15:26 GMT List processes using swap - rowty.net code snippets (echo "COMM PID SWAP"; for file in /proc/*/status ; do awk '/^Pid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | grep -wv "0 kB" | sort -k 3 -n -r) | column -t https://rowty.net/view/105/1/List-processes-using-swap https://rowty.net/view/105/1/List-processes-using-swap Fri, 8 Dec 2017 14:19:51 GMT Force logrotate in centos 6.x - rowty.net code snippets # Force logrotate to run and rotate the logs logrotate -f /etc/logrotate.conf https://rowty.net/view/104/1/Force-logrotate-in-centos-6.x https://rowty.net/view/104/1/Force-logrotate-in-centos-6.x Tue, 28 Nov 2017 12:49:39 GMT Change CentOS 7 hostname - rowty.net code snippets # First, use the hostnamectl command hostnamectl set-hostname "super.rowty.net" # Then, update the /etc/hosts file using your favorite editor (vim) https://rowty.net/view/103/1/Change-CentOS-7-hostname https://rowty.net/view/103/1/Change-CentOS-7-hostname Wed, 15 Nov 2017 09:19:25 GMT Grab two variables from a two column text file - rowty.net code snippets #!/bin/bash while read VAR1 VAR2; do # Do stuff here echo $VAR2 echo $VAR1 done </path/to/input-file https://rowty.net/view/102/1/Grab-two-variables-from-a-two-column-text-file https://rowty.net/view/102/1/Grab-two-variables-from-a-two-column-text-file Thu, 2 Nov 2017 09:36:12 GMT Using netcat, check for UDP port open - rowty.net code snippets # First, log into the server and use tcpdump to listen to a port via udp: tcpdump -i eth0 udp port 8080 -vv -X # Then, on your client, connect via nc to the server nc -u $server 8080 # Next, type some text on the client, you should see it on the server side. https://rowty.net/view/101/1/Using-netcat--check-for-UPD-port-open https://rowty.net/view/101/1/Using-netcat--check-for-UPD-port-open Tue, 15 Aug 2017 13:27:17 GMT Using Nmap-Netcat nc on Centos 7 - rowty.net code snippets nc -w 2 -v canyouseeme.org 80 </dev/null; echo $? https://rowty.net/view/100/4/Using-Nmap-Netcat-nc-on-Centos-7 https://rowty.net/view/100/4/Using-Nmap-Netcat-nc-on-Centos-7 Fri, 21 Jul 2017 14:11:10 GMT Remove Duplicates inside the VIM file. - rowty.net code snippets # Run the following command in VI editor to remove any duplicates :1,$ !uniq https://rowty.net/view/99/4/Remove-Duplicates-inside-the-VIM-file. https://rowty.net/view/99/4/Remove-Duplicates-inside-the-VIM-file. Fri, 21 Jul 2017 13:41:15 GMT