Skip to content

Instantly share code, notes, and snippets.

View sumitsaiwal's full-sized avatar

Sumit Kumar sumitsaiwal

View GitHub Profile
@sumitsaiwal
sumitsaiwal / Install Docker
Last active October 8, 2018 04:44
Docker installation for Ubuntu 16.04
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
#sudo apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install -y docker-engine
#sudo apt-cache policy docker-engine
#sudo apt-get install -y docker-engine=1.13.1-0~ubuntu-xenial
sudo service docker start
@sumitsaiwal
sumitsaiwal / service principal for Azure Container Service
Last active March 2, 2018 01:36
Service principal for a Kubernetes cluster in Container Service using Azure CLI
##Connect to ACS##https://docs.microsoft.com/en-us/azure/container-service/dcos-swarm/container-service-connect
##Kubectl.exe: https://storage.googleapis.com/kubernetes-release/release/v1.9.3/bin/windows/amd64/kubectl.exe
##clientID==appId
##cleintPassword==password
az login
az account set --subscription "mySubscriptionID"
az group create --name "myResourceGroup" --location "westus"
@sumitsaiwal
sumitsaiwal / Azure vpn root client certificate
Last active January 31, 2018 06:28
powershell command used to create certificates for point to site connectivity
root
$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature `
-Subject "CN=P2SRootCert" -KeyExportPolicy Exportable `
-HashAlgorithm sha256 -KeyLength 2048 `
-CertStoreLocation "Cert:\CurrentUser\My" -KeyUsageProperty Sign -KeyUsage CertSign
Client
@sumitsaiwal
sumitsaiwal / Docker connect to remote server.md
Created January 2, 2018 09:25 — forked from kekru/Docker connect to remote server.md
Connect to another host with your docker client, without modifying your local Docker installation

Run commands on remote Docker host

This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

Enable Docker Remote API

First be sure to enable the Docker Remote API on the remote host.

This can easily be done with a container.
For HTTP connection use jarkt/docker-remote-api.
For HTTPS connection use whiledo/docker-remote-api-tls.

sudo sed -i 's/PermitRootLogin prohibit-password/#PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/#PasswordAuthentication no/g' /etc/ssh/sshd_config
sudo sed -i '$ a PermitRootLogin yes' /etc/ssh/sshd_config
sudo sed -i '$ a PasswordAuthentication yes' /etc/ssh/sshd_config
sudo sed -i '$ a PermitRootLogin without-password' /etc/ssh/sshd_config
echo PASSWORD | sudu passwd
sudo service ssh restart (ubuntu)
sudo service sshd restart (rhel)
import boto
import boto.iam #**************Importing the Identity and access management****
import win32com.client as win32 #******Importing windows application module***
import random
import string
import time
#******************for SMTP integration**************************
import smtplib
from email.mime.multipart import MIMEMultipart
#!/usr/bin/env python
# Simple [boto3](https://github.com/boto/boto3) based EC2 manipulation tool
#
# To start an instance, create a yaml file with the following format:
#
# region_name:
# - subnet-id or subnet_tag_name:
# - type: t2.micro
# image: image-tagname or AMI-Id
instance_id=$(aws ec2 run-instances --region us-east-1 --key $USER --instance-type t1.micro --image-id ami-d9a98cb0 --output text --query 'Instances[*].InstanceId')
echo instance_id=$instance_id
while state=$(aws ec2 describe-instances --instance-ids $instance_id --output text --query 'Reservations[*].Instances[*].State.Name'); test "$state" = "pending"; do
sleep 1; echo -n '.'
done; echo " $state"
ip_address=$(aws ec2 describe-instances --instance-ids $instance_id --output text --query 'Reservations[*].Instances[*].PublicIpAddress')
echo ip_address=$ip_address
aws ec2 get-console-output --instance-id $instance_id --output text |
perl -ne 'print if /BEGIN SSH .* FINGERPRINTS/../END SSH .* FINGERPRINTS/'
ssh ubuntu@$ip_address
$ami_id = Read-Host 'AMI-ID'
$instance_type = Read-Host 'Instance type'
$instance_name = Read-Host 'Tags_Name'
$count = Read-Host 'Instance count'
$region = Read-Host 'Region'
$key_pair = Read-Host 'Ker-Pair name'
$security_group = Read-Host 'Security-Group name'
#$security_group_id = Read-Host 'Security-Group-ID'
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName 'my-subscription-name'
$rgName = 'my-resource-group-name'
$vmName = 'my-vm-name'
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
$vm.StorageProfile.OSDisk.DiskSizeGB = 1023
Update-AzureRmVM -ResourceGroupName $rgName -VM $vm
Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName