ssh access allowgroups

If unable to login via SSH, check the /etc/ssh/sshd_config for AllowGroups. AllowGroups root groupname It’s case sensitive.

September 16, 2019 · 1 min · ulysses

aws security groups ip cidr

Here’s how to search for AWS Security Groups containing this IP Cidr. aws ec2 describe-security-groups \ --filter Name=egress.ip-permission.cidr,Values='10.8.8.8/32' \ --query "SecurityGroups[*].{Name:GroupName}" \ --output text \ --profile default \ --region us-east-1 Search with ports. aws ec2 describe-security-groups \ --filter Name=egress.ip-permission.cidr,Values='10.8.8.8/32' \ Name=egress.ip-permission.from-port,Values='22' \ Name=egress.ip-permission.to-port,Values='22' \ --query "SecurityGroups[*].{Name:GroupName}" \ --output text \ --profile default \ --region us-east-1 Query will only display the Security Group name.

September 10, 2019 · 1 min · ulysses

migrate gcp vm to another network

Here are the steps how to migrate a GCP VM from one network to another. It involves recreating the instance in that network. Find the VM. Click the ‘Create Similar’ button. Select the new network. Save Network. Everything else should stay the same. Don’t click Create, but get the ‘Create Similar’ command line script only. Click Cancel after. Make sure to edit the hostname. GCP appends a ‘-1’ at the end of hostname. Edit VM to keep all disks. Delete VM. Make sure to preserve boot drive. Run the ‘Create Similar’ command line script you capture to create new VM in the new network. The new VM will be based on golden image. Stop VM. Swap new disks with old disks. Start VM. Done.

September 10, 2019 · 1 min · ulysses

phpinfo blank page

Here’s how to fix when phpinfo is displaying a blank page. The install is missing this php module. apt install php libapache2-mod-php Restart after install. service apache2 restart

September 10, 2019 · 1 min · ulysses

run shell script from your website

Here’s how to run a shell script from your website. You’ll need 2 files. Here’s the contents of foo.php. Wrap your output with ‘pre’ for better formatting. <?php $output = shell_exec('/var/www/html/bar.sh 2?>&1'); echo "$output"; Here’s the content of bar.sh. Output will be displayed on web page. #!/bin/bash now="$(date +'%y%m%d')" echo $now aws s3 ls

September 10, 2019 · 1 min · ulysses

rsync only new files

Here’s how to sync files between two directories, while copying only new files and ignoring existing files. rsync --ignore-existing -rapzvh /dir1 /dir2 >> /root/rsync.log &

September 9, 2019 · 1 min · ulysses

display last 50 posts in archive page

Here’s the code to add to your archive template, e.g. archives.php. Last 50 Posts: wp_get_archives( array( 'type' =?> 'postbypost', 'limit' =&gt; 50, 'format' =&gt; '', 'before' =&gt; '- ', 'after' =&gt; ' ' )); ?>

September 8, 2019 · 1 min · ulysses

view contents of tar file

Here’s how to view the contents of a tar file without extracting the files. tar -tvf file.tar

September 8, 2019 · 1 min · ulysses

wordpress numeric pagination

Here’s how to add numeric pagination on your WordPress pages. Add this code to functions.php. function pagination($pages = '', $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo '<p></p><div class="pagination"><span>Page' . $paged . ' of ' . $pages . '</span> '; if($paged > 2 && $paged > $range+1 && $showitems '; if($paged > 1 && $showitems '; for ($i=1; $i = $paged+$range+1 || $i ' . $i . '' : '<a class="inactive" href="' . get_pagenum_link($i) . '">' . $i . '</a>'; } } if ($paged Next >'; if ($paged Last >>'; echo '</div>'; } } To display, comment out ‘the_post_navigation’ function and add the ‘pagination’ function instead in your template files. ...

September 8, 2019 · 1 min · ulysses

get directory size

Here’s how to get the size of a directory. du -sh /var/www Output: 2.1GB /var/www Size of the directories and files one level down. du -sh /var/www/* Sort with biggest files from top to bottom. du -sh /var/www/* | sort -rh Top 5 biggest files from top to bottom. du -sh /var/www/* | sort -rh | head -5

September 7, 2019 · 1 min · ulysses