Skip to content

Instantly share code, notes, and snippets.

@paul-hohberg
paul-hohberg / dig_cmds.txt
Created June 28, 2022 21:28
Useful dig commands.
#Get nameservers
dig github.com NS +short
#Dig specific nameserver
dig @ns-1283.awsdns-32.org github.com +short
#Get mail servers
dig github.com MX +short
#Reverse lookup
dig -x 192.30.255.112 +short
#Get zone records NS,MX,TXT,ttl, and SOA
dig +nocmd +multiline +noall +answer any github.com
@paul-hohberg
paul-hohberg / robocopy.txt
Created June 28, 2022 21:27
Robocopy mirror with multithread, FAT file times, restartable, no hidden files, wait 5 secs., retry 5 times, output to logfile.
robocopy <local source path> <remote target path> /MT /MIR /FFT /Z /XA:H /W:5 /R:5 /log:<log file path>
@paul-hohberg
paul-hohberg / aws_snowball_cmds.txt
Created June 28, 2022 21:25
Useful AWS Snowball client commands.
#install cifs utils for SMB mount
sudo apt install cifs-utils
#mount SMB share
sudo mkdir /mnt/share_name
sudo mount -t cifs //server/share /mnt/share_name -o user=username,domain=domain_name
#start snowball client
snowball start -i snowball_ip -m snowball_manifest.bin -u user_key
#copy to snowball in background
nohup snowball cp -r /mnt/share_name s3://bucket/dir &
#stop snowball client
@paul-hohberg
paul-hohberg / event_log_user_query.xml
Created June 28, 2022 21:23
File to perform user query against Windows event log.
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">* [EventData[Data[@Name='subjectUsername']='user']]</Select>
</Query>
</QueryList>
@paul-hohberg
paul-hohberg / rclone.txt
Created June 28, 2022 21:11
rclone commands with progress shown
rclone sync /local_directory remote:bucket/directory -P
rclone check /local_directory remote:bucket/directory -P --size-only
@paul-hohberg
paul-hohberg / resolv_symlink.sh
Created June 28, 2022 21:08
Change resolv.conf symlink on Ubuntu Server 18.0.4
@paul-hohberg
paul-hohberg / get-active-ad-computer-accts.ps1
Created June 28, 2022 21:03
PowerShell command to determine the number of active computer accounts in Active Directory and display them by OU
Get-ADComputer -SearchBase “OU=company,DC=domain,DC=com” -Filter {Enabled -eq $true} -Properties CanonicalName | Group-Object {Split-Path $_.CanonicalName} | FT -Property Count, Name -AutoSize
@paul-hohberg
paul-hohberg / windows_dhcp_svr_cfg_export-import.txt
Created June 28, 2022 20:52
PowerShell commands to export and import a Windows DHCP server configuration.
# Export Windows DHCP server configuration
Export-DhcpServer -ComputerName "dhcp1.company.com" -File "C:\exports\dhcp-config.xml"
# Import Windows DHCP server configuration
Import-DhcpServer -ComputerName "dhcp2.company.com" -File "C:\exports\dhcp-config.xml" -BackupPath "C:\dhcpbackup\"
@paul-hohberg
paul-hohberg / ssh_priv_pub_comp.txt
Created February 22, 2022 17:40
Compare ssh private and public key signatures to determine if they match.
ssh-keygen -l -f id_rsa
ssh-keygen -l -f id_rsa.pub
@paul-hohberg
paul-hohberg / regen_ssh_host_keys.txt
Created January 14, 2022 22:50
How to regenerate OpenSSH host keys
/bin/rm -v /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
systemctl restart ssh