Skip to content

Instantly share code, notes, and snippets.

View Pristavkin's full-sized avatar

Alexey Pristavkin Pristavkin

  • 01:32 (UTC +03:00)
View GitHub Profile
@Pristavkin
Pristavkin / hyper-v-static-ip.md
Last active July 26, 2022 11:41 — forked from mzaglia/hyper-v-static-ip.md
Static IP Hyper-V Ubuntu VM

First in a powershell create a new network switch

New-VMSwitch -SwitchName "Hyper-V [VM NAT]" -SwitchType Internal
Get-NetAdapter       // (note down ifIndex of the newly created switch as INDEX)
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex <INDEX>
New-NetNat -Name HyperV-NATnetwork -InternalIPInterfaceAddressPrefix 192.168.0.0/24

In your ubuntu server open your network netplan

@Pristavkin
Pristavkin / Ansible mass rename of Pi users.md
Last active February 1, 2022 13:57
Ansible mass rename of Pi users

Nice ansible playbook and supplemental Makefile for bulk change of default username on raspberry pi running on raspbian distribution. It can be easily modified for mass changing passwords on any templated virtual machines or devices. For use just run: make rename_pi_user i=10.0.0.1,10.0.0.2,10.0.3

@Pristavkin
Pristavkin / 41_Windows
Last active February 10, 2020 19:16
RHEL/CentOS GRUB dualboot Winows config
#!/bin/sh
# 1. Place this file to /etc/grub.d/05_Windows
# 2. Update Windows patrtition setting. In this example Winodws will be booted from hd0,1 - sda2 partition ("hd0" is sda, and ",1" is second partition on disk)
# 3. Add "GRUB_DEFAULT=saved" and "GRUB_SAVEDEFAULT=true" lines to /etc/default/grub for save last booted OS
# 4. Run "chmod +x /etc/grub.d/41_Windows && grub2-mkconfig --output=/boot/grub2/grub.cfg" after all modifications for make new config file
exec tail -n 5 $0
menuentry "Windows 10" {
savedefault
set root=(hd0,1)
chainloader +1
@Pristavkin
Pristavkin / IintToBridge
Created August 3, 2019 07:22
RHEL/CentOS move eth to bridge
#!/bin/sh
export MAIN_CONN=enp5s0f0
bash -x <<EOS
systemctl stop libvirtd
nmcli c delete "$MAIN_CONN"
nmcli c delete "Wired connection 1"
nmcli c add type bridge ifname br0 autoconnect yes con-name br0 stp off
#nmcli c modify br0 ipv4.addresses 192.168.1.99/24 ipv4.method manual
#nmcli c modify br0 ipv4.gateway 192.168.1.1
#nmcli c modify br0 ipv4.dns 192.168.1.1
@Pristavkin
Pristavkin / ssh-keyscan.py
Last active May 25, 2020 05:51
Python implementation of ssh-keyscan utility
#!/usr/bin/env python3
import argparse
import paramiko
import os.path
parser = argparse.ArgumentParser()
parser.add_argument('host', action='store', help='host to connect to')
parser.add_argument('-p', '--port', action='store', dest='port', default='22', help='port to connect to')
parser.add_argument('--known_hosts', action='store', dest='known_hosts', default='~/.ssh/known_hosts', help='known_hosts file')
args = parser.parse_args()