<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>General &#8211; Blog of Kliment Andreev &#8211; A place so I won&#039;t forget things</title>
	<atom:link href="https://blog.andreev.it/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.andreev.it</link>
	<description></description>
	<lastBuildDate>Tue, 18 Nov 2025 00:45:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>General: Tips &#038; Tricks and one-liners (Part IV)</title>
		<link>https://blog.andreev.it/2023/04/general-tips-tricks-and-one-liners-part-iv/</link>
					<comments>https://blog.andreev.it/2023/04/general-tips-tricks-and-one-liners-part-iv/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Thu, 13 Apr 2023 12:49:08 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<guid isPermaLink="false">https://blog.andreev.it/?p=9343</guid>

					<description><![CDATA[Part I, Part II, Part III. Install go (golang) on Rocky Linux 8 As&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p><a href="https://blog.andreev.it/?p=134" rel="noopener noreferrer" target="_blank">Part I</a>, <a href="https://blog.andreev.it/?p=203" rel="noopener noreferrer" target="_blank">Part II</a>, <a href="https://blog.andreev.it/?p=5117" rel="noopener noreferrer" target="_blank">Part III</a>.</p>
<h1>Install go (golang) on Rocky Linux 8</h1>
<p>As the user developing in Go, remove if you have any old versions. On new installs, not needed.</p>
<pre class="brush: bash; title: ; notranslate">
sudo yum module -y remove go-toolset
</pre>
<p>Download the latest version and make it executable.</p>
<pre class="brush: bash; title: ; notranslate">
wget https://storage.googleapis.com/golang/getgo/installer_linux
chmod +x ./installer_linux
</pre>
<p>Run the installer.</p>
<pre class="brush: bash; title: ; notranslate">
./installer_linux 
</pre>
<p>You&#8217;ll get a message <em>&#8230;One more thing! Run source &#8230;</em>. Do as it says, run the <strong>source </strong>command.<br />
Test with <strong>go version</strong>.</p>
<h1>Add entries under Windows 11 Terminal</h1>
<p>Go to <strong>%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState</strong> folder and open <strong>settings.json</strong> file. Under the <em>&#8220;list&#8221;</em> section, add a new entry. Here is an example with opacity and background image for SSH access with a key. Go to <a href="https://guidgenerator.com/" rel="noopener" target="_blank">this </a>site, generate a GUID and replace the value.</p>
<pre class="brush: xml; title: ; notranslate">
            {
                &quot;backgroundImage&quot;: &quot;C:\\Some-Folder\\wallpaper.jpg&quot;,
                &quot;backgroundImageOpacity&quot;: 0.25,
                &quot;commandline&quot;: &quot;ssh -i \&quot;C:\\Random-Folder\\keys\\MyKeyPair.pem\&quot; username@hostname.com&quot;,
                &quot;guid&quot;: &quot;{dee15512-fc2f-416d-ac0f-961378b46f6e}&quot;,
                &quot;hidden&quot;: false,
                &quot;name&quot;: &quot;Name-in-the-dropdown-list&quot;
            },

</pre>
<h1>Install Office 365 using Office Deployment Tool</h1>
<p>1) Download <a href="https://www.microsoft.com/en-us/download/details.aspx?id=49117" rel="noopener" target="_blank">Office Deployment Tool</a><br />
2) Run and extract somewhere<br />
3) Go to this <a href="https://config.office.com/deploymentsettings" rel="noopener" target="_blank">link </a>and configure your settings<br />
4) In my case I used:</p>
<ul>
&#8211; 64-bit Business Apps<br />
&#8211; No Visio and Project<br />
&#8211; Current channel<br />
&#8211; Latest</ul>
<p>5) Choose the apps that you want installed<br />
6) Check the other settings, pretty much default<br />
7) Click <strong>Export </strong>to download an XML file and put this file in the same folder as the Office Deployment Tool<br />
8) From an admin command prompt type <em>setup.exe /download &lt;filename.xml&gt;</em><br />
9) The previous command will download the whole Office suite. You&#8217;ll see an Office folder in the same directory where ODT tool is installed.<br />
10) Finally type <em>setup.exe /configure &lt;filename.xml&gt;</em></p>
<h1>Non-functional requirements</h1>
<p>Non-functional requirements (<strong>NFRs</strong>), also known as quality attributes or system qualities, are essential aspects of software development that describe how a system should perform rather than what it should do. These requirements help ensure that the application meets certain performance, security, scalability, and usability standards. Here are some common categories of non-functional requirements for an application:</p>
<p>    <strong>Performance</strong>:</p>
<ul>
<li>Response Time: Define the maximum allowable response times for different operations or transactions.</li>
<li>Throughput: Specify the number of transactions or operations the system should handle per unit of time.</li>
<li>Scalability: Describe how the application should scale to accommodate increased load.</li>
</ul>
<p>    <strong>Reliability</strong>:</p>
<ul>
<li>Availability: Define the percentage of time the system should be available for use.</li>
<li>Fault Tolerance: Specify how the system should handle and recover from failures.</li>
<li>Recovery: Describe the time and methods required to recover from failures or disasters.</li>
</ul>
<p>    <strong>Security</strong>:</p>
<ul>
<li>Authentication and Authorization: Define how users are authenticated and what actions they are authorized to perform.</li>
<li>Data Encryption: Specify the encryption standards for data in transit and at rest.</li>
<li>Access Control: Describe how sensitive data and system resources are protected from unauthorized access.</li>
</ul>
<p>    <strong>Usability</strong>:</p>
<ul>
<li>User Interface: Define the user interface design principles, accessibility standards, and usability guidelines.</li>
<li>User Experience: Specify user interaction and navigation expectations.</li>
</ul>
<p>    <strong>Scalability and Capacity</strong>:</p>
<ul>
<li>Load Handling: Describe how the system should handle increasing loads, such as more users or data.</li>
<li>Resource Utilization: Specify the maximum acceptable resource utilization, such as CPU, memory, and storage.</li>
</ul>
<p>    <strong>Maintainability</strong>:</p>
<ul>
<li>Modifiability: Describe how easily the system can be modified or extended.</li>
<li>Code Quality: Specify coding standards, code documentation, and code review processes.</li>
</ul>
<p>    <strong>Interoperability</strong>:</p>
<ul>
<li>Integration Standards: Define how the application should interact with other systems or platforms.</li>
<li>Data Format Compatibility: Specify data exchange formats and protocols.</li>
</ul>
<p>    <strong>Compliance and Legal Requirements</strong>:</p>
<ul>
<li>Regulatory Compliance: Ensure that the application complies with relevant laws and regulations.</li>
<li>Data Privacy: Specify how sensitive data is handled to comply with data protection regulations.</li>
</ul>
<p>    <strong>Performance Metrics and Monitoring:</strong></p>
<ul>
<li>Logging and Monitoring: Describe the logging and monitoring requirements for tracking system performance and errors.</li>
<li>Alerting: Define the conditions that trigger alerts or notifications for system administrators.</li>
</ul>
<p>    <strong>Localization and Internationalization:</strong></p>
<ul>
<li>Localization: Specify requirements for adapting the application to different languages and regions.</li>
<li>Internationalization: Define design principles that enable easy adaptation to different languages and regions.</li>
</ul>
<p>    <strong>Operational Requirements:</strong></p>
<ul>
<li>Deployment: Describe how the application should be deployed, including hardware and software requirements.</li>
<li>Business Continuity: Specify backup and recovery procedures.</li>
<li>RACI model: Define who is responsible, accountable, consulted and informed for the application components.</li>
</ul>
<p>    <strong>Documentation:</strong></p>
<ul>
<li>User Documentation: Describe user manuals, help guides, and other user-facing documentation.</li>
<li>Technical Documentation: Specify technical documentation for developers, including APIs and system architecture.</li>
</ul>
<p>These non-functional requirements are crucial for defining the overall quality and performance of an application, and they help guide the development, testing, and deployment processes to ensure that the system meets its intended goals and functions effectively in its operational environment. The specific NFRs for an application will vary based on its unique requirements and context.</p>
<h1>Reference your own public IP in Terraform group</h1>
<p>If you want to add your own home IP to a security group, e.g. you want to restrict access to an instance for your home computer only, this is the Terraform script. </p>
<pre class="brush: bash; title: ; notranslate">
data &quot;http&quot; &quot;myip&quot; {
  url = &quot;http://ipv4.icanhazip.com&quot;
}

module &quot;instance_security_group&quot; {
  source  = &quot;terraform-aws-modules/security-group/aws&quot;
  version = &quot;5.1.0&quot;

  name    = &quot;sgInstances&quot;
  vpc_id  = module.vpc.vpc_id

  ingress_with_self = &#x5B;{
    rule = &quot;all-all&quot;
  }]

  ingress_with_cidr_blocks = &#x5B;
    {
      rule        = &quot;ssh-tcp&quot;
      cidr_blocks = &quot;${chomp(data.http.myip.response_body)}/32&quot;
    },
  ]
}
</pre>
<h1>Update AWS EKS cluster in kubeconfig</h1>
<pre class="brush: bash; title: ; notranslate">
aws eks update-kubeconfig --name &lt;cluster_name&gt;
</pre>
<h1>AWS SSO token expiration</h1>
<p>If you receive an e-mail that your IdP token expires (&#8220;We&#8217;re contacting you because you automatically provision users and groups from your corporate identity provider (IdP) to IAM Identity Center, a process which uses the SCIM protocol (System for Cross-domain Identity Management). The SCIM access token used to automatically provision users and groups from your IdP to IAM Identity Center expires in 82 days on Fri Jan 05 13:40:46 UTC 2024.&#8221;), do the following:</p>
<ul>
<li>Log to the Master Account for your Org</li>
<li>Go to IAM Identity Center</li>
<li>Click <strong>Settings</strong> on the left and <strong>Manage token</strong> on the right.</li>
<li>Click <strong>Generate Token</strong></li>
</ul>
<p>Verify that the token works and then delete the old one. </p>
<h1>Dynamic auto-provisioning of persistent volumes and claims on a bare-metal Kubernetes server</h1>
<p>If you have a bare-metal or VM running Kubernetes and you need some dynamic provisioning of persistent volumes and persistent volume claims on an NFS server, read further.<br />
Install NFS CSI driver for Kubernetes. </p>
<pre class="brush: bash; title: ; notranslate">
curl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/v4.4.0/deploy/install-driver.sh | bash -s v4.4.0 --
</pre>
<p>Install the nfs-subdir-external-provisioner. </p>
<pre class="brush: bash; title: ; notranslate">
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
    --set nfs.server=x.x.x.x \
    --set nfs.path=/exported/path
</pre>
<p>It creates a storage class for you.</p>
<pre class="brush: bash; title: ; notranslate">
kubectl get sc
NAME         PROVISIONER                                     RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-client   cluster.local/nfs-subdir-external-provisioner   Delete          Immediate           true                   2d3h
</pre>
<p>Check the <a href="https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner" rel="noopener" target="_blank">docs</a>.<br />
You need the nfs-utils on nfs-tools installed on the underlying OS. Otherwise, you&#8217;ll get an error in the pods saying that mount nfs can not be found or something like that.<br />
Anytime there is a need for storage, just specify the storageClass as nfs-client in the manifest. The volumes and claims will be provisioned for you automatically.<br />
If you use NFSv4 use the root as exported path, e.g. &#8211;set nfs.path=/</p>
<h1>NFSv4 on FreeBSD</h1>
<p>Add these in /etc/rc.conf</p>
<pre class="brush: bash; title: ; notranslate">
rpcbind_enable=&quot;YES&quot;
nfs_server_enable=&quot;YES&quot;
mountd_enable=&quot;YES&quot;
nfsv4_server_enable=&quot;YES&quot;
nfsv4_server_only=&quot;YES&quot;
</pre>
<p>This is the /etc/exports file</p>
<pre class="brush: bash; title: ; notranslate">
V4: /nfs -network 192.168.1.0/24 
/nfs -network 192.168.1.0/24
</pre>
<p>Mount from Linux.</p>
<pre class="brush: bash; title: ; notranslate">
sudo mount -t nfs -o vers=4.0 192.168.1.26:/ /mnt
</pre>
<h1>Install Kube Prometheus stack on NFS and behind ngninx ingress on MetalLB load balancer</h1>
<p>You need MetalLB and nginx ingress for this. Read <a href="https://blog.andreev.it/2023/10/install-metallb-on-kubernetes-cluster-running-on-vmware-vms-or-bare-metal-server/" rel="noopener" target="_blank">here</a>. </p>
<pre class="brush: bash; title: ; notranslate">
helm install -f kps-custom.yaml kps prometheus-community/kube-prometheus-stack -n monitoring
</pre>
<p>File kps-custom.yaml.</p>
<pre class="brush: bash; title: ; notranslate">
prometheus:
  prometheusSpec:    
    storageSpec: 
     volumeClaimTemplate:
       spec:
         storageClassName: nfs-client
         accessModes: &#x5B;&quot;ReadWriteOnce&quot;]
         resources:
           requests:
             storage: 10Gi
alertmanager:
  alertmanagerSpec:
      storage: 
        volumeClaimTemplate:
          spec:
            storageClassName: nfs-client
            accessModes: &#x5B;&quot;ReadWriteOnce&quot;]
            resources:
                requests:
                  storage: 10Gi
</pre>
<p>Create a MetalLB load balancer.</p>
<pre class="brush: bash; title: ; notranslate">
kubectl expose deployment kps-grafana --port 80 --target-port 3000 --name=grafana-lb --type=LoadBalancer -n monitoring
</pre>
<p>or with a manifest.</p>
<pre class="brush: bash; title: ; notranslate">
apiVersion: v1
kind: Service
metadata:
  name: example-service
  namespace: monitoring
spec:
  selector:
    app: kps-grafana
  ports:
    - port: 80
      targetPort: 3000
  type: LoadBalancer
</pre>
<p>Username and password: admin / prom-operator<br />
If you want to use nginx ingress on already configured MetalLB load balancer, there is no need to do kubectl expose deployment kps-grafana&#8230;Just add these lines at the end of kps-custom.yaml and update the chart.</p>
<pre class="brush: bash; title: ; notranslate">
grafana:
  ingress:
    enabled: true
    ingressClassName: nginx
    annotations: {}
      # kubernetes.io/ingress.class: nginx
      # kubernetes.io/tls-acme: &quot;true&quot;
    labels: {}
    hosts:
      - grafana.iandreev.com

    ## Path for grafana ingress
    path: /

    ## TLS configuration for grafana Ingress
    ## Secret must be manually created in the namespace
    ##
    tls: &#x5B;]
    # - secretName: grafana-general-tls
    #   hosts:
    #   - grafana.example.com
</pre>
<h1>Install KubeCost on NFS</h1>
<p>Install KubeCost and MetalLB load balancer. You need MetalLB and nginx ingress for this. Read <a href="https://blog.andreev.it/2023/10/install-metallb-on-kubernetes-cluster-running-on-vmware-vms-or-bare-metal-server/" rel="noopener" target="_blank">here</a>. </p>
<pre class="brush: bash; title: ; notranslate">
helm install kubecost kubecost/cost-analyzer -n kubecost  --set kubecostToken=&quot;aGVsbUBrdWJlY29zdC5jb20=xm343yadf98&quot; \
--set prometheus.server.persistentVolume.storageClass=nfs-client --set persistentVolume.storageClass=nfs-client
kubectl expose deployment kubecost-cost-analyzer --port 80 --target-port 9090 --name=kubecost-lb --type=LoadBalancer -n kubecost
</pre>
<p>The commands above are enough to create Kubecost deployment and a MetalLB load balancer. If you want nginx ingress read further.<br />
If you already have nginx ingress, skip the last line and do the following. The username/password is optional, but if you are exposing kubecost publicly, then you want some type of authentication.</p>
<pre class="brush: bash; title: ; notranslate">
sudo dnf install httpd-tools
httpasswd -c auth admin
</pre>
<p>The commands above will download httpd-tools and then prompt you to create a password for the admin as user. The output is written in a file called auth.<br />
Create a Kubernetes secret from that file. You can delete the file, it&#8217;s not needed anymore after the command below.</p>
<pre class="brush: bash; title: ; notranslate">
kubectl create secret generic kubecost-basic-auth --from-file=auth -n kubecost
</pre>
<p>Check if everything looks OK.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
kubectl get secret kubecost-basic-auth -o yaml -n kubecost
apiVersion: v1
data:
  auth: YWW46Jsomethinghere!$#ASEDFdwasfasWESDCAVsdcewqEwyMAo=
kind: Secret
metadata:
  creationTimestamp: &quot;2023-10-26T17:24:47Z&quot;
  name: kubecost-basic-auth
  namespace: default
  resourceVersion: &quot;3561042&quot;
  uid: 8ad981c2-4a4d-4488-9a38-9873286f4efa
type: Opaque
</pre>
<p>Create this file. I named it kubecost-ingress-auth.yaml. Specify the secret name at line 8 and your FQDN at line 13.</p>
<pre class="brush: bash; highlight: [8,13]; title: ; notranslate">
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kubecost
  namespace: kubecost
  annotations:
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/auth-secret: kubecost-basic-auth
    nginx.ingress.kubernetes.io/auth-realm: &#039;Authentication Required - kubecost&#039;
spec:
  ingressClassName: nginx
  rules:
  - host: kubecost.iandreev.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: kubecost-cost-analyzer
            port:
              number: 9090
#  tls:
#  - hosts:
#      - kubecost.your.com
#    secretName: kubecost-tls
# Use any cert tool/cert-manager or create manually: kubectl create secret tls kubecost-tls --cert /etc/letsencrypt/live/kubecost.your.com/fullchain.pem --key /etc/letsencrypt/live/kubecost.your.com/privkey.pem
</pre>
<p>Then create the ingress.</p>
<pre class="brush: bash; title: ; notranslate">
kubectl apply -f kubecost-ingress-auth.yaml
</pre>
<h1>Connect to a remote Kubernetes cluster/Merge config files</h1>
<ul>
<li>Make a backup of the current .kube/config file</li>
<li>Transfer the config file from the remote cluster to the local machine and save it as config_new</li>
<li>
Run this command: </p>
<pre class="brush: bash; title: ; notranslate">KUBECONFIG=~/.kube/config:~/.kube/config_new kubectl config view --flatten &gt; ~/.kube/config</pre>
</li>
<li>Install kubectx tool and run it without any parameters</li>
<li>Switch to the remote cluster using kubectx some_name</li>
</ul>
<h1>Ubuntu 22 &#8211; Change from DHCP to static IP, change hostname</h1>
<p>As root or sudo create or edit <strong>/etc/netplan/01-netcfg.yaml</strong> file.<br />
Add these lines to specify the network card (line 5), IP and subnet mask (line 7), DNS (line 9) and the gateway (line 12).</p>
<pre class="brush: bash; highlight: [5,7,9,12]; title: ; notranslate">
network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
                - 192.168.1.212/24
            nameservers:
                addresses: &#x5B;8.8.8.8, 8.8.4.4]
            routes:
                - to: default
                  via: 192.168.1.1
</pre>
<p>Change the hostname using:</p>
<pre class="brush: bash; title: ; notranslate">
sudo hostnamectl set-hostname pihole.homelab.local
</pre>
<p>Edit <strong>/etc/hosts</strong> and change the 2nd localhost line to specify FQDN.</p>
<pre class="brush: bash; highlight: [2]; title: ; notranslate">
127.0.0.1 localhost
127.0.1.1 pihole.homelab.local

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
</pre>
<h1>VMWare Tools on CentOS/Rocky Linux/Red Hat</h1>
<pre class="brush: bash; title: ; notranslate">
dnf install open-vm-tools
</pre>
<p>For desktop use open-vm-tools-desktop</p>
<h1>Passwordless login</h1>
<ul>
<li>Do <strong>ssh-keygen</strong>  on the client machine</li>
<li>From the client machine do <strong>ssh-copy-id user@ip-hostname-of-the-server</strong> or copy id_rsa.pub to <strong>.ssh/authorized_keys</strong> on the SSH server</li>
</ul>
<h1>Resize FreeBSD ZFS partition</h1>
<p>Find the disk from the pool.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
zpool status
  pool: zroot
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        zroot       ONLINE       0     0     0
          da0p3     ONLINE       0     0     0

errors: No known data errors
</pre>
<p>In my case the disk is <strong>da0</strong>. The partition is <strong>da0p3</strong>.<br />
Check the size of the disk. You should see the extra space added (4G).</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
gpart show
=&gt;      40  25165751  da0  GPT  (12G)
        40      1024    1  freebsd-boot  (512K)
      1064       984       - free -  (492K)
      2048   4194304    2  freebsd-swap  (2.0G)
   4196352  12578816    3  freebsd-zfs  (6.0G)
  16775168   8390623       - free -  (4.0G)
</pre>
<p>If you see that the GPT says corrupt, execute <em>gpart recover da0</em>.<br />
Resize the 3rd partition <em>freebsd-zfs</em>. </p>
<pre class="brush: bash; title: ; notranslate">
gpart resize -i 3 -s 10200M da0
</pre>
<p>Check the pools.</p>
<pre class="brush: bash; title: ; notranslate">
zpool list
</pre>
<p>If the size didn&#8217;t change, resize the pool where <strong>zroot </strong>is the name of the pool and <strong>da0p3 </strong>is the name of the partition. Get them with <em>zpool status</em>.</p>
<pre class="brush: bash; title: ; notranslate">
zpool online -e zroot da0p3
</pre>
<p>If you do <em>zpool list</em> this time, you&#8217;ll see that the partition was resized.<br />
If you want for the pool to auto expand next time, you have to change the setting.</p>
<pre class="brush: bash; title: ; notranslate">
zpool set autoexpand=on zroot
</pre>
<p>If you this, next time you resize the partition with <em>gpart</em>, you won&#8217;t have to do <em>zpool online</em> command.</p>
<h1>Node.js update on Ubuntu</h1>
<p>Check all Node.js editions.</p>
<pre class="brush: bash; title: ; notranslate">
nvm list-remote
</pre>
<p>Check current running.</p>
<pre class="brush: bash; title: ; notranslate">
node --version
</pre>
<p>Also&#8230;</p>
<pre class="brush: bash; title: ; notranslate">
nvm list
</pre>
<p>Update from the remote-list. It automatically switches to default.</p>
<pre class="brush: bash; title: ; notranslate">
nvm install v20.11.0
</pre>
<p>Use specific version.</p>
<pre class="brush: bash; title: ; notranslate">
nvm use v20.10.0
</pre>
<h1>Increase disk size on Ubuntu 22</h1>
<p>Expand the disk space in vCenter or AWS Console. Boot up and type <strong>cfdisk</strong>.<br />
Select the partition which size you want to increase and select <strong>Resize</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2023/04/P162-01.png"><img fetchpriority="high" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2023/04/P162-01.png" alt="" width="841" height="405" class="aligncenter size-full wp-image-9859" srcset="https://blog.andreev.it/wp-content/uploads/2023/04/P162-01.png 841w, https://blog.andreev.it/wp-content/uploads/2023/04/P162-01-300x144.png 300w, https://blog.andreev.it/wp-content/uploads/2023/04/P162-01-768x370.png 768w, https://blog.andreev.it/wp-content/uploads/2023/04/P162-01-585x282.png 585w" sizes="(max-width: 841px) 100vw, 841px" /></a><br />
Then select <strong>Write </strong>and confirm. Exit the tool.<br />
Because we added the free space to /dev/sda3, we have to resize the physical volume.</p>
<pre class="brush: bash; title: ; notranslate">
pvresize /dev/sda3
</pre>
<p>Type <strong>vgdisplay</strong>. You should see that you have extra space under <strong>Free PE/Size</strong>.<br />
Extend the logical volume with all (100%) available free space.</p>
<pre class="brush: bash; title: ; notranslate">
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
</pre>
<p>Now resize the filesystem.</p>
<pre class="brush: bash; title: ; notranslate">
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
</pre>
<p>Verify with df -h.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              197M  1.1M  196M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   37G   15G   21G  43% /
tmpfs                              982M     0  982M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          1.7G  253M  1.4G  16% /boot
/dev/sda1                          571M  6.1M  565M   2% /boot/efi
tmpfs                              197M  4.0K  197M   1% /run/user/1000
</pre>
<h1>RDP to an AzureAD (Entra ID) joined computer</h1>
<p>If the RDP client computer is also joined to AzureAD (Entra ID) then, most likely you&#8217;ll just get prompted for username and password or PIN. You might also want to disable NLA.</p>
<pre class="brush: powershell; title: ; notranslate">
REM Disable the Network Level Authentication
reg add &quot;HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp&quot; /v UserAuthentication /t REG_DWORD /d 0
</pre>
<p>If the RDP client is joined to another AD, then you have to add these two lines in the RDP file. Just edit it as a text file.</p>
<pre class="brush: bash; title: ; notranslate">
enablerdsaadauth:i:0
enablecredsspsupport:i:0
</pre>
<p>If you want to save the password in the RDP file, encrypt your password first.</p>
<pre class="brush: powershell; title: ; notranslate">
(&quot;SuperSecretPassword01!&quot; | ConvertTo-SecureString -AsPlainText -Force) | ConvertFrom-SecureString;
</pre>
<p>Then add this line at the end of the RDP file. </p>
<pre class="brush: bash; title: ; notranslate">
password 51:&lt;the output of the previous PowerShell command&gt;
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2023/04/general-tips-tricks-and-one-liners-part-iv/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>General: How to stream/broadcast from your phone</title>
		<link>https://blog.andreev.it/2020/05/general-how-to-stream-broadcast-from-your-phone/</link>
					<comments>https://blog.andreev.it/2020/05/general-how-to-stream-broadcast-from-your-phone/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Sun, 03 May 2020 13:47:48 +0000</pubDate>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[broadcast]]></category>
		<category><![CDATA[Larix]]></category>
		<category><![CDATA[SRT]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[VLC]]></category>
		<guid isPermaLink="false">https://blog.andreev.it/?p=6678</guid>

					<description><![CDATA[In this short article I&#8217;ll describe briefly how to stream/broadcast from your phone&#8217;s camera&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>In this short article I&#8217;ll describe briefly how to stream/broadcast from your phone&#8217;s camera to the world. In order to do that, you&#8217;ll need the <strong>Larix Broadcaster</strong> app installed on your phone, you will need a server with a public IP and a <strong>Haivision Media Gateway</strong> installed and for the end users, they&#8217;ll need standard <strong>VLC Player</strong> install.<br />
The Larix Broadcaster app and the VLC player are free, but Haivision Media Gateway is not. In addition, if you have your own server and want to install it as a VM, you&#8217;ll have to contact the vendor directly. I&#8217;ll use a much easier option and host it in AWS where it comes as a template from the <a href="https://aws.amazon.com/marketplace/pp/Haivision-Haivision-Media-Gateway-PAYG/B014VA1JZ4" rel="noopener noreferrer" target="_blank">AWS Marketplace</a>.</p>
<h1>Haivision Media Gateway in AWS</h1>
<p>In AWS, launch a new instance from the AWS Marketplace and search for SRT. You&#8217;ll see several options(SRT Gateway vs. Media Gateway and BYOL as PAYG license). I&#8217;ll choose Pay-as-You-Go Media Gateway.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-01.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-01.png" alt="" width="1357" height="191" class="aligncenter size-full wp-image-6680" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-01.png 1357w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-300x42.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-1024x144.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-768x108.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-1170x165.png 1170w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-01-585x82.png 585w" sizes="(max-width: 1357px) 100vw, 1357px" /></a><br />
As you can see, the software is not that cheap and you pay as much as you used. So if you are not streaming, just shut down the instance. Another important thing is the size of the instance, how much horse power you need. Is it 2 CPUs, 4 CPUs, 8? Well, nobody knows your needs, but it also depends on what type of stream are you sending, is it going to be a low-res or 1080p, how many users will consume that stream, etc. I strongly suggest that you go over this <a href="https://doc.haivision.com/additional-resources/srt-deployment-guide" rel="noopener noreferrer" target="_blank">document</a>. It describes how to size your environment and it gives you practical guidance on how to configure the Media Gateway. It&#8217; not a necessary read to continue with this post, but it&#8217;s strongly recommended once you have everything up and running.<br />
OK, in my case I&#8217;ll go with a t3.medium instance which is 2 CPUs and 4GB RAM. Create the instance as you normally do, make sure you have a public IP and the ports that are recommended in the security group given are open (22, 80 and 443). Once the instance boots up log with the default username <strong>haiadmin </strong>and the password is your instance id which is <strong>i-0123something</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-02.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-02.png" alt="" width="468" height="488" class="aligncenter size-full wp-image-6681" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-02.png 468w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-02-288x300.png 288w" sizes="(max-width: 468px) 100vw, 468px" /></a><br />
I won&#8217;t go into details what each option does and what each keyword means, I&#8217;ll just guide you through creating a route for you to be able to broadcast. So, from the screen that you see, click on the button to add a route.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-03.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-03.png" alt="" width="1061" height="137" class="aligncenter size-full wp-image-6682" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-03.png 1061w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-300x39.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-1024x132.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-768x99.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-03-585x76.png 585w" sizes="(max-width: 1061px) 100vw, 1061px" /></a><br />
These are my parameters. For the <strong>Route Name</strong>, enter a description and make sure the checkmark is checked for Start Route. Further down, enter a description for the <strong>Source Name</strong>, in my case it&#8217;s Larix Cam or whatever you want to put here. The <strong>Protocol </strong>is <strong>TS Over SRT</strong> and the port is <strong>50000</strong>. The <strong>Mode </strong>is <strong>Listener </strong>and the rest are the defaults. As I said earlier, if you want a better throughput, read the SRT deployment guide doc that I&#8217;ve sent earlier. It will tell you how to tweak these parameters. So, this tells the Media Gateway to listen on port UDP 50000 for any incoming broadcast.<br />
Now, click on the <strong>Destination </strong>button.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-05.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-05.png" alt="" width="1082" height="131" class="aligncenter size-full wp-image-6683" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-05.png 1082w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-300x36.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-1024x124.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-768x93.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-05-585x71.png 585w" sizes="(max-width: 1082px) 100vw, 1082px" /></a><br />
The <strong>Destination </strong>is where the broadcast will be distributed. So, you got the point now. A camera on your phone sends the video to our instance in AWS and this instance (Media Gateway) distributes the feed to numerous viewers. You can&#8217;t stream from your phone directly, because your phone&#8217;s bandwidth and horse power are minuscule, so you need a gateway.<br />
Here is how the <strong>Destination </strong>looks like.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-06.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-06.png" alt="" width="657" height="753" class="aligncenter size-full wp-image-6684" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-06.png 657w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-06-262x300.png 262w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-06-585x670.png 585w" sizes="(max-width: 657px) 100vw, 657px" /></a><br />
Name the destination however you like, make sure the <strong>Protocol </strong>is <strong>TS over SRT</strong> and the <strong>Port </strong>is 50001. The Media Gateway passes the signal from UDP 50000 (source) to UDP 50001 (destination). Can you use some other ports? Yes, you can as long as they are not the same and greater than 1024 and less than 65535. Change the <strong>Type </strong>to <strong>Listener </strong>and leave the rest of the parameters as-is. Again, read the SRT Deployment Guide. Click <strong>Add </strong>and once you go back, click <strong>Create </strong>to create the route.<br />
<strong>SUPER IMPORTANT</strong>: Make sure you edit the security group for this instance and open the ports for the source and destination. In my case, you have to add UDP ports 50000 and 50001 to the rules of the security group.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-07.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-07.png" alt="" width="1094" height="527" class="aligncenter size-full wp-image-6685" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-07.png 1094w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-300x145.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-1024x493.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-768x370.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-07-585x282.png 585w" sizes="(max-width: 1094px) 100vw, 1094px" /></a></p>
<h1>Larix Broadcaster app</h1>
<p>On your phone download this app from Google Play or App Store. Go to <strong>Settings </strong>(the gear icon), <strong>Connections </strong>and click on the <strong>(+)</strong> sign to add a connection.<br />
Enter a name for your connection, and for the URL enter the public IP of your instance and the port of the listener, so it looks like <strong>srt://public_IP:port</strong>. Make sure you specify <strong>srt://</strong> as prefix. The defaults are 640&#215;480 with audio, but you can change that in the settings for the app. Now, that you have a connection, make sure it&#8217;s active by selecting it and after that just hit the <strong>Record </strong>button. If something is not right, you&#8217;ll see it right away on your camera. It will tell you that the app can&#8217;t connect to the server. And if everything is OK after about 8-10 seconds you&#8217;ll see a green dot next to your source in the Media Gateway.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-09.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-09.png" alt="" width="1039" height="134" class="aligncenter size-full wp-image-6687" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-09.png 1039w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-300x39.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-1024x132.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-768x99.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-09-585x75.png 585w" sizes="(max-width: 1039px) 100vw, 1039px" /></a></p>
<h1>VLC PLayer</h1>
<p>There is really nothing much to say here. Go to <a href="https://www.videolan.org/vlc/index.html" rel="noopener noreferrer" target="_blank">this </a>website, download and install <strong>VLC </strong>and from the menu click on <strong>Media | Open Network Stream</strong>. Enter the IP address of the AWS instance and specify the destination port like <strong>srt://public_IP:port</strong>. Make sure you specify the destination port, not the source port and the protocol should be srt.</p>
<h1>Stream a video file (optional)</h1>
<p>In case you want your source to be a video file instead of a camera stream, reconfigure the source or add another route with new source and destination of which the source is RTMP. Configure the source so it looks like this.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/05/P149-10.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/05/P149-10.png" alt="" width="1096" height="819" class="aligncenter size-full wp-image-6690" srcset="https://blog.andreev.it/wp-content/uploads/2020/05/P149-10.png 1096w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-300x224.png 300w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-1024x765.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-768x574.png 768w, https://blog.andreev.it/wp-content/uploads/2020/05/P149-10-585x437.png 585w" sizes="(max-width: 1096px) 100vw, 1096px" /></a><br />
From another server send the video stream to the Media Gateway using this command (you need ffmpeg installed).</p>
<pre class="brush: bash; title: ; notranslate">
ffmpeg -re -i video-file.mp4 -c copy -f flv rtmp://media_gateway_ip/live/stream
</pre>
<p>In VLC, use the <strong>srt://media_gateway_ip:port</strong> to watch the stream.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2020/05/general-how-to-stream-broadcast-from-your-phone/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>General: Tips &#038; Tricks and one-liners (Part III)</title>
		<link>https://blog.andreev.it/2019/03/general-tips-tricks-and-one-liners-part-iii/</link>
					<comments>https://blog.andreev.it/2019/03/general-tips-tricks-and-one-liners-part-iii/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Sat, 16 Mar 2019 13:00:00 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<guid isPermaLink="false">https://blog.andreev.it/?p=5117</guid>

					<description><![CDATA[Part I, Part II, Part IV. WordPress – prevent unauthorized admin logins If you&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p><a href="https://blog.andreev.it/?p=134" rel="noopener noreferrer" target="_blank">Part I</a>, <a href="https://blog.andreev.it/?p=203" rel="noopener noreferrer" target="_blank">Part II</a>, <a href="https://blog.andreev.it/?p=9343" rel="noopener noreferrer" target="_blank">Part IV. </p>
<h1>WordPress – prevent unauthorized admin logins</h1>
<p>If you have a WordPress blog, you probably know that there are tons of attempts from users/scripts to try to take over your blog and post spam. There are a lot of plugins there that can take care of different security aspects, but by far, this simple solution works best for me.<br />
It prevents anyone except white listed IPs to access your login page. Instead they&#8217;ll get error 404, page not found. The only problem is that you can&#8217;t have your own user base. So, if someone wants to post a comment, it can&#8217;t be a user registered on your blog. I use the <a href="http://www.oneall.com/" target="_blank" rel="noopener noreferrer">Social Login</a> plugin that allows users to login and register with one click on this blog, using their own social network&#8217;s logins.</p>
<p>Anyway, you need <strong>mod_rewite</strong> installed on your web server. Look for this line and if it&#8217;s commented, remove the <strong>#</strong> and reload the config.</p>
<pre class="brush: bash; title: ; notranslate">
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
</pre>
<p>In the root of your blog, edit the <strong>.htaccess</strong> file and make sure it looks like this.<br />
In my example, I have only two IPs allowed that can access the wp-login page. The rest will get page not found when accessing wp-login.php or wp-admin.</p>
<pre class="brush: bash; title: ; notranslate">
ErrorDocument 401 /index.php?error=404
ErrorDocument 403 /index.php?error=404

 &lt;IfModule mod_rewrite.c&gt;
 RewriteEngine on
 RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ &#x5B;OR]
 RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
 RewriteCond %{REMOTE_ADDR} !^198.16.3.247$
 RewriteCond %{REMOTE_ADDR} !^24.184.123.233$
 RewriteRule ^(.*)$ - &#x5B;R=403,L]
 &lt;/IfModule&gt;
 # BEGIN protect xmlrpc.php
 &lt;files xmlrpc.php&gt;
 order allow,deny
 deny from all
 &lt;/files&gt;
 # END protect xmlrpc.php
</pre>
<h1>AWS: ssh to a server with private IP only</h1>
<p>I was playing with some servers in AWS. One of them had a public IP, but the second one had a private IP only. In order to access the 2nd server with private IP only, open up the key that was given to you for the 2nd server by AWS in PEM format in your favorite text editor. Select the text and copy it to the clipboard. The key looks like this. This key should belong to the 2nd server.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2019/03/P128-01.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2019/03/P128-01.png" alt="" width="457" height="353" class="aligncenter size-full wp-image-8478" srcset="https://blog.andreev.it/wp-content/uploads/2019/03/P128-01.png 457w, https://blog.andreev.it/wp-content/uploads/2019/03/P128-01-300x232.png 300w" sizes="(max-width: 457px) 100vw, 457px" /></a><br />
Now, log to the first server with the public IP as <strong>ec2-user</strong>.<br />
Create a new file with nano or vi and paste the content. Save it as <strong>some_file.pem</strong>.<br />
Change the permissions.</p>
<pre class="brush: bash; title: ; notranslate">
chmod 600 some_file.pem
</pre>
<p>Then log to the 2nd server with the private IP.</p>
<pre class="brush: bash; title: ; notranslate">
ssh -i some_file.pem &lt;internal_IP&gt;
</pre>
<h1>NTP sync in a domain environment</h1>
<p>On the PDC domain controller.</p>
<pre class="brush: bash; title: ; notranslate">
w32tm /config /manualpeerlist:&quot;0.us.pool.ntp.org 1.us.pool.ntp.org 2.us.pool.ntp.org 3.us.pool.ntp.org&quot; /syncfromflags:manual /reliable:yes /update 
</pre>
<p>On all other DCs.</p>
<pre class="brush: bash; title: ; notranslate">
w32tm /config /syncfromflags:domhier /update 
</pre>
<p>Resync manually.</p>
<pre class="brush: bash; title: ; notranslate">
w32tm.exe /resync /rediscover
</pre>
<p>Check the status.</p>
<pre class="brush: bash; title: ; notranslate">
w32tm /query /status
</pre>
<h1>Ubunty 18 &#8211; DNS</h1>
<p>First, configure the YAML file <strong>/etc/netplan</strong>, do <strong>netplan apply</strong> and then&#8230;</p>
<pre class="brush: bash; title: ; notranslate">
sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
</pre>
<h1>Ubuntu 18 &#8211; Change hostname</h1>
<pre class="brush: bash; title: ; notranslate">
hostnamectl set-hostname &lt;new_hostname&gt;
</pre>
<p>Edit <strong>/etc/cloud/cloud.cfg</strong> and replace <strong>preserve_hostname: false</strong> to <strong>true</strong></p>
<h1>Change Windows password from command line prompt</h1>
<p>Open up PowerShell/CMD with admin privileges and type:</p>
<pre class="brush: bash; title: ; notranslate">
net user username new_password
</pre>
<h1>FreeBSD vmtools in vCenter</h1>
<p>If you want to install VMWare Tools in FreeBSD running in vCenter, install this package.</p>
<pre class="brush: bash; title: ; notranslate">
pkg -y install open-vm-tools-nox11
</pre>
<p>If you want the full tools that cover X11, install open-vm-tools without &#8220;-nox11&#8221; suffix in the above command.<br />
Edit /etc/rc.conf and add these lines.</p>
<pre class="brush: yaml; title: ; notranslate">
vmware_guest_vmblock_enable=&quot;YES&quot;
vmware_guest_vmhgfs_enable=&quot;NO&quot;
vmware_guest_vmmemctl_enable=&quot;YES&quot;
vmware_guest_vmxnet_enable=&quot;YES&quot;
vmware_guestd_enable=&quot;YES&quot;
</pre>
<h1>FreeBSD change from DHCP to static IP, default gateway and DNS</h1>
<p>Edit <strong>/etc/rc.conf</strong> and you&#8217;ll see a ifconfig DHCP assignment somewhere. Change the DHCP keyword with your static IP and netmask and don&#8217;t forget the default gateway.</p>
<pre class="brush: bash; title: ; notranslate">
ifconfig_vmx0=&quot;inet 192.168.1.11 netmask 255.255.255.0&quot;
defaultrouter=&quot;192.168.1.1&quot;
</pre>
<p>The DNS settings are under <strong>/etc/resolv.conf</strong>.</p>
<h1>Find Wireless (WiFi) password</h1>
<pre class="brush: bash; title: ; notranslate">
netsh wlan show profile &lt;SSID&gt; key=clear
</pre>
<h1>Install git 2 on CentOS 7 from source</h1>
<pre class="brush: bash; title: ; notranslate">
yum -y groupinstall &quot;Development Tools&quot;
yum -y install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel wget
wget https://github.com/git/git/archive/v2.23.0.tar.gz -O /tmp/git.tgz
cd /tmp
tar xzvf git.tgz 
cd git*
make configure
./configure
make install
cd /tmp
rm -Rf git*
</pre>
<h1>Use git with a private key and no password</h1>
<p>Anytime you push, clone or pull a repo, you&#8217;ll get prompted for a password which is kind of annoying. Do this to use a private key access and never get prompted for a password again. On your Linux workstation, make changes in line 2 and 3 and do:</p>
<pre class="brush: bash; title: ; notranslate">
cd
git config --global user.name &quot;Kliment Andreev&quot;
git config --global user.email &quot;klimenta@iandreev.com&quot;
ssh-keygen -t rsa -b 4096
cat .ssh/id_rsa.pub
</pre>
<p>Go to GitHub, in the upper-right corner click on the avatar, choose <strong>Settings </strong>and then <strong>SSH and GPG</strong> keys. Click to add a key, name it and paste the output from the <strong>ssh-keygen</strong> command above.<br />
You have to change the remote origin to use SSH instead of HTTPS.</p>
<pre class="brush: bash; title: ; notranslate">
git remote set-url origin git@github.com:&lt;github_username&gt;/&lt;github_repo&gt;
</pre>
<h1>vi &#8211; use spaces instead of tabs</h1>
<p>Add this to ~/.vimrc</p>
<pre class="brush: bash; title: ; notranslate">
set tabstop=2 shiftwidth=2 expandtab
</pre>
<h1>Replace tabs with spaces in vi</h1>
<pre class="brush: bash; title: ; notranslate">
:%s/\t/ /g
</pre>
<h1>Replace tabs with spaces in files</h1>
<pre class="brush: bash; title: ; notranslate">
sed -i &#039;s/\t/ /g&#039; *
</pre>
<h1>S3 bucket policy for static web hosting</h1>
<pre class="brush: xml; title: ; notranslate">
{
    &quot;Version&quot;: &quot;2012-10-17&quot;,
    &quot;Statement&quot;: &#x5B;
        {
            &quot;Sid&quot;: &quot;PublicReadGetObject&quot;,
            &quot;Effect&quot;: &quot;Allow&quot;,
            &quot;Principal&quot;: &quot;*&quot;,
            &quot;Action&quot;: &#x5B;
                &quot;s3:GetObject&quot;
            ],
            &quot;Resource&quot;: &#x5B;
                &quot;arn:aws:s3:::example-bucket/*&quot;
            ]
        }
    ]
}
</pre>
<h1>Ansible execute playbook locally</h1>
<pre class="brush: bash; title: ; notranslate">
ansible-playbook --connection=local --inventory 127.0.0.1, ansible.yml
</pre>
<h1>Import AWS key from another region</h1>
<p>Best practice is to have separate keys for all instances, but if you need &#8220;one key to rule them all&#8221; instances, you have to create a public key from your private key and import it in AWS keys.<br />
Let&#8217;s say your private key is something.key.</p>
<pre class="brush: bash; title: ; notranslate">
ssh-keygen -y -f something.key &gt; something.pem
</pre>
<p>Now, cat out the pem file and paste it under AWS key import.</p>
<h1>vi tabs, spaces</h1>
<p>Edit <strong>.virc</strong> or <strong>.vimrc</strong> and add this line</p>
<pre class="brush: bash; title: ; notranslate">
set tabstop=2 shiftwidth=2 expandtab
</pre>
<p>Convert tabs to spaces in existing file -> <strong>:retab</strong></p>
<h1>Log to AWS CLI using SSO</h1>
<p>This tip requires an SSO configured, see this <a href="https://blog.andreev.it/?p=8872" rel="noopener" target="_blank">link</a>.<br />
Configure the SSO with <strong>aws sso configure</strong> once or multiple times for multiple profiles.<br />
Then use <strong>aws sso login</strong>, a browser will pop up, log in and close the browser.<br />
Export the profile you want to use, e.g. export <strong>AWS_PROFILE=dev</strong>, then <strong>aws sts get-caller-identity</strong>.<br />
At this point use any CLI commands, e.g. <strong>aws s3 ls</strong>. </p>
<h1>AWS IAM Identity Center (successor to AWS Single Sign-On) SCIM Access Token Approaching Expiration</h1>
<p>If you received an e-mail from AWS that your token expires, open up the first two links at the bottom of the e-mail. The first one opens up your AWS console where the token is and the second one opens up a tutorial on how to create a new token. Create a new access token, but do not delete the old one. Copy the value (not the token ID), but the value that it will be presented to you only once.<br />
Now, go to Azure, under Azure Active Directory, find the AWS SSO enterprise app and open it and from the left side on the screen, click on <strong>Provisioning</strong>. Expand the <strong>Admin Credentials</strong> and paste the token from AWS under <strong>Secret Token</strong>. Click <strong>Test Connection</strong> and if everything is OK, click <strong>Save </strong>and you are good and you can delete the old token in AWS.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2019/03/general-tips-tricks-and-one-liners-part-iii/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>General: Transfer a domain from 1and1.com to godaddy.com</title>
		<link>https://blog.andreev.it/2013/12/transfer-a-domain-from-1and1-com-to-godaddy-com/</link>
					<comments>https://blog.andreev.it/2013/12/transfer-a-domain-from-1and1-com-to-godaddy-com/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Mon, 16 Dec 2013 16:54:44 +0000</pubDate>
				<category><![CDATA[Editor's Pick]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[1 & 1]]></category>
		<category><![CDATA[domain transfer]]></category>
		<category><![CDATA[GoDaddy]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=981</guid>

					<description><![CDATA[In this post I&#8217;ll describe the current procedure of migrating a domain that&#8217;s registered&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>In this post I&#8217;ll describe the current procedure of migrating a domain that&#8217;s registered and hosted at <a href="http://www.1and1.com" target="_blank" rel="noopener noreferrer">1and1.com</a> to <a href="http://www.godaddy.com" target="_blank" rel="noopener noreferrer">godaddy.com</a>. The reason for my migration is simple. I just want to move all my registered domains to godaddy.com and consolidate them. In addition, since I purchased some <a href="http://en.wikipedia.org/wiki/Virtual_private_server" target="_blank" rel="noopener noreferrer">VPS</a>, I&#8217;ve decided to migrate my stuff to a full-blown server instead of renting web hosting from 1and1.com</p>
<p>First log to your 1and1.com domain panel and click <strong>Manage domains</strong>.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-01.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-01.png" alt="" width="918" height="267" class="aligncenter size-full wp-image-6801" /></a></p>
<p>Select the domain that you want to transfer (in my case iandreev.com), click <strong>Transfers</strong> and choose <strong>Lock/Unlock</strong> option.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-02.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-02.png" alt="" width="763" height="223" class="aligncenter size-full wp-image-6802" /></a></p>
<p>Select <strong>Unlock</strong>.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-03.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-03.png" alt="" width="688" height="297" class="aligncenter size-full wp-image-6803" /></a></p>
<p>ICANN regulations prohibit transferring domain names (except .au) that were registered or previously transferred in the last 60 days, so if you already transferred your domain in the past two months, you won&#8217;t be able to do so.</p>
<p>Back in the domain panel, select the domain again and click <strong>Info</strong>.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-04.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-04.png" alt="" width="917" height="240" class="aligncenter size-full wp-image-6855" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-04.png 917w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-04-300x79.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-04-768x201.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-04-585x153.png 585w" sizes="(max-width: 917px) 100vw, 917px" /></a></p>
<p>You should see something similar to this. The most important thing here is the last line <strong>&#8220;Auth code.com&#8221;</strong> and its value.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-05.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-05.png" alt="" width="475" height="292" class="aligncenter size-full wp-image-6837" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-05.png 475w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-05-300x184.png 300w" sizes="(max-width: 475px) 100vw, 475px" /></a></p>
<p>Log to your account at go daddy.com and go to this link.</p>
<p><a href="http://www.godaddy.com/domains/domain-transfer.aspx">http://www.godaddy.com/domains/domain-transfer.aspx</a></p>
<p>When you see this page:<br />
<a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-06.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-06.png" alt="" width="701" height="294" class="aligncenter size-full wp-image-6838" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-06.png 701w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-06-300x126.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-06-585x245.png 585w" sizes="(max-width: 701px) 100vw, 701px" /></a></p>
<p>Type the domain name that you want to transfer and click <strong>Go</strong>. At the top, you&#8217;ll see the domain name, just verify it and click <strong>Proceed to Checkout</strong>.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-07.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-07.png" alt="" width="734" height="347" class="aligncenter size-full wp-image-6839" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-07.png 734w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-07-300x142.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-07-585x277.png 585w" sizes="(max-width: 734px) 100vw, 734px" /></a></p>
<p>You&#8217;ll get some offers but they are not worth it, so just skip this step and click <strong>Continue</strong>.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-08.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-08.png" alt="" width="720" height="533" class="aligncenter size-full wp-image-6840" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-08.png 720w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-08-300x222.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-08-585x433.png 585w" sizes="(max-width: 720px) 100vw, 720px" /></a></p>
<p>Review the current order and pay the transfer fees.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-09.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-09.png" alt="" width="1067" height="584" class="aligncenter size-full wp-image-6841" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-09.png 1067w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-09-300x164.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-09-1024x560.png 1024w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-09-768x420.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-09-585x320.png 585w" sizes="(max-width: 1067px) 100vw, 1067px" /></a></p>
<p>Once your payment is approved, usually instantly click on <strong>Domain Name</strong> image.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-10.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-10.png" alt="" width="995" height="522" class="aligncenter size-full wp-image-6842" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-10.png 995w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-10-300x157.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-10-768x403.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-10-585x307.png 585w" sizes="(max-width: 995px) 100vw, 995px" /></a></p>
<p>Within a minute or two, you’ll receive this e-mail, so make sure you have access to the mailbox that was used when your domain was registered.</p>
<pre class="brush: plain; title: ; notranslate">
Kliment Andreev, approve your transfer request.

====================================================================
DOMAIN NAME TRANSFER - Initial Authorization for Registrar Transfer
====================================================================

Re: Transfer of IANDREEV.COM

Dear Kliment Andreev,

GoDaddy received a request on December 09, 2013 for us to become the new registrar of record.

You received this message because you're listed as the Registered Name Holder or Administrative contact for this domain name. If you're not the Account Holder, or you're transferring the domain to a new owner, please forward this email to the appropriate Account Holder to complete the transfer process.

///////////////////////////////////////////////////////////
IMPORTANT: If the steps below are not completed, the domain name(s) listed above will NOT be transferred to us.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When authorizing this transfer, you'll be prompted to provide the following Transfer IDs:

Transaction ID: 159067416
Security Code: OYVB28941

To proceed with the transfer, follow the instructions here:
http://support.godaddy.com/help/article/1592?prog_id=GoDaddy&isc=gdbbx2&ci=83387
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

NOTE: After a domain transfer is complete, you cannot transfer it to another registrar for 60 days, apart from transferring back to the original registrar in cases where both registrars so agree or where a decision in the dispute resolution process so directs.

If you DO NOT WANT the transfer to proceed, do not respond to this message.

If you have any questions about this process, contact us by email at support@godaddy.com, or by phone at (480) 505-8877.

Regards,
GoDaddy

Search for a new domain:
http://www.godaddy.com/domains/search.aspx?prog_id=GoDaddy&isc=gdbbx2&ci=83389

Go to My Account:
https://mya.godaddy.com/myrenewals/myrenewals.aspx?shopperid=2529155&prog_id=GoDaddy&myatabs=false&isc=gdbbx2&ci=83385

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Copyright (C) 1999-2013 GoDaddy.com, LLC. All rights reserved.


</pre>
<p>Next, click on <strong>Domains</strong>, then <strong>Transfers</strong> tab and click the green <strong>Launch</strong> image.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-11.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-11.png" alt="" width="980" height="251" class="aligncenter size-full wp-image-6843" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-11.png 980w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-11-300x77.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-11-768x197.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-11-585x150.png 585w" sizes="(max-width: 980px) 100vw, 980px" /></a></p>
<p>Click on <strong>Authorization code needed</strong>. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-12.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-12.png" alt="" width="921" height="180" class="aligncenter size-full wp-image-6844" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-12.png 921w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-12-300x59.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-12-768x150.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-12-585x114.png 585w" sizes="(max-width: 921px) 100vw, 921px" /></a></p>
<p>Then click <strong>Add now</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-13.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-13.png" alt="" width="662" height="411" class="aligncenter size-full wp-image-6845" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-13.png 662w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-13-300x186.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-13-585x363.png 585w" sizes="(max-width: 662px) 100vw, 662px" /></a></p>
<p>Enter the <strong>Transaction ID</strong> and <strong>Security Code</strong> from the e-mail that you just received.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-14.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-14.png" alt="" width="599" height="327" class="aligncenter size-full wp-image-6846" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-14.png 599w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-14-300x164.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-14-585x319.png 585w" sizes="(max-width: 599px) 100vw, 599px" /></a><br />
Click <strong>Next</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-15.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-15.png" alt="" width="654" height="342" class="aligncenter size-full wp-image-6847" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-15.png 654w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-15-300x157.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-15-585x306.png 585w" sizes="(max-width: 654px) 100vw, 654px" /></a></p>
<p>When prompted for the <strong>Authorization Code</strong>, enter the code from 1and1.com (Info button).</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-16.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-16.png" alt="" width="665" height="423" class="aligncenter size-full wp-image-6848" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-16.png 665w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-16-300x191.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-16-585x372.png 585w" sizes="(max-width: 665px) 100vw, 665px" /></a></p>
<p>You’ll see a short notice that the domain transfer is in process, but you’ll end up with a prompt to enter the <strong>Authorization Code</strong> again. </p>
<p>Just hit F5 and you’ll see this.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-17.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-17.png" alt="" width="846" height="165" class="aligncenter size-full wp-image-6849" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-17.png 846w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-17-300x59.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-17-768x150.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-17-585x114.png 585w" sizes="(max-width: 846px) 100vw, 846px" /></a></p>
<p>After 2 hours I received an email from 1and1.com.</p>
<pre class="brush: plain; title: ; notranslate">
Dear Mr. Andreev,

Thank you for your transfer request for your domain iandreev.com
on 2013-12-10 04:01:39.We are happy to provide you with more
detailed information.

The current transfer status of your domain is: off.

Do you want to revoke the transfer of your domain? Simply change the
status to &quot;Lock&quot; in your 1&amp;amp;1 Control Panel. To do so, go to:

https://www.1and1.com/login

If you still want your domain to be transferred, please make sure the
status of your domain is set to &quot;Unlock&quot;. The transfer of your domain
will then be completed automatically on 2013-12-15 04:01:39.

If your domain is locked, the transfer will be automatically canceled on
2013-12-14 04:01:39.

IMPORTANT: Please note that upon the domain transfer your domain as
well as all associated rights will be transferred to the new registrant -
thus to the new owner of the domain. This means that your domain, together
will all subdomains and e-mail accounts using this domain name, will be
removed from your contract.

Therefore, please make sure that you only agree to this domain transfer
if you have initiated it yourself or if you have already agreed on all
details with the new registrant.

Please find below a step-by-step instruction on how to lock or unlock
your domain for the transfer:

1. Log in to your 1&amp;amp;1 Control Panel with your customer data at
https://www.1and1.com/login.

2. Select the package containing the respective domain. Click on &quot;Domains&quot;
under &quot;Domains &amp;amp; Web Space&quot;. You can lock or unlock your domain by selecting
the domain from the list and then clicking on &quot;Transfers&quot;/&quot;Lock/Unlock&quot;.

If you cannot log in to your 1&amp;amp;1 Control Panel, please contact our
1&amp;amp;1 Customer Support via the following e-mail address:

support@1and1.com.

Please note our Terms and Conditions at https://www.1and1.com/Gtc. Please
refer to our FAQ section at http://faq.1and1.com/domains/domain_xfers/xfer_of_reg/index.html
for further information.

Yours sincerely,

1&amp;1 Internet Inc.


</pre>
<p>The only important part in this e-mail is this “<em>The transfer of your domain will then be completed automatically on 2013-12-15 04:01:39”</em>. If everything goes well, after a week you’ll receive an email from godaddy.com that looks like this.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-18.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-18.png" alt="" width="663" height="532" class="aligncenter size-full wp-image-6850" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-18.png 663w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-18-300x241.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-18-585x469.png 585w" sizes="(max-width: 663px) 100vw, 663px" /></a><br />
Click on <strong>Go to My Account</strong> and once you log in, click on <strong>Domains</strong>. Select the domain that you just transferred, click on the <strong>Nameservers</strong> icon and then click on <strong>Set Nameservers</strong>.  </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-19.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-19.png" alt="" width="1018" height="471" class="aligncenter size-full wp-image-6851" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-19.png 1018w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-19-300x139.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-19-768x355.png 768w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-19-585x271.png 585w" sizes="(max-width: 1018px) 100vw, 1018px" /></a></p>
<p>Click on <strong>Standard</strong> to change the DNS servers to GoDaddy’s DNS servers.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2013/12/P034-20.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2013/12/P034-20.png" alt="" width="634" height="450" class="aligncenter size-full wp-image-6852" srcset="https://blog.andreev.it/wp-content/uploads/2013/12/P034-20.png 634w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-20-300x213.png 300w, https://blog.andreev.it/wp-content/uploads/2013/12/P034-20-585x415.png 585w" sizes="(max-width: 634px) 100vw, 634px" /></a></p>
<p>Mind that when you are changing the DNS, all the sub domains that you had with 1 and 1 will be gone. You’ll have to recreate them under Go Daddy’s panel, so make sure that you have a migration plan for all of your sub domains and the data associated.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2013/12/transfer-a-domain-from-1and1-com-to-godaddy-com/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>General: NetApp / Virtual Connect &#8211; connect without a switch</title>
		<link>https://blog.andreev.it/2012/12/netapp-virtual-connect-connect-without-a-switch/</link>
					<comments>https://blog.andreev.it/2012/12/netapp-virtual-connect-connect-without-a-switch/#comments</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Mon, 24 Dec 2012 20:16:13 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Virtual Connect]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=512</guid>

					<description><![CDATA[Recently, I had to connect a NetApp device with our HP blades in c7000&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>Recently, I had to connect a NetApp device with our HP blades in c7000 chassis, using a straight connection (meaning no switch in between). It took some significant time to make this thing work, because the connection between a NetApp storage device and HP Virtual Connect is supposed to be configured using a switch, not a straight and direct connection. </p>
<h1>Cabling</h1>
<p>There are two Virutal Connect modules in the HP c7000 chassis and two dual-head 10Gb NICs in each NetApp controller. Each Virtual Connect module is using ports x7 and x8. This is how the ports are connected. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-01.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-01.png" alt="" width="720" height="310" class="aligncenter size-full wp-image-6224" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-01.png 720w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-01-300x129.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-01-585x252.png 585w" sizes="(max-width: 720px) 100vw, 720px" /></a></p>
<ul>
<li>Port x7 on the first VC1 (Virtual Connect) module is connected to the NIC e3b on the first controller with a blue FC cable</li>
<li>Port x8 on the first VC1 module is connected to the NIC e3b on the second controller with a yellow FC cable</li>
<li>Port x7 on the second VC2 module is connected to the NIC e3a on the first controller with a green FC cable</li>
<li>Port x8 on the second VC2 module is connected to the NIC e3a on the second controller with a gray FC cable</li>
</ul>
<p><strong>NOTE: When looking the NetApp controllers, NIC e3b is on left and NIC e3a is on the right side, as shown on the image above.</strong></p>
<h1>NetApp configuration</h1>
<p>This is how the NICs are configured on the first controller. In case something goes wrong, these lines must be in /etc/rc on each controller. Otherwise, when the controllers are rebooted, these configuration changes will be lost. </p>
<pre class="brush: bash; title: ; notranslate">
ifconfig e3a down
ifconfig e3b down
ifgrp create single Trunk10 e3a e3b
vlan create Trunk10 10
ifconfig Trunk10-10 192.168.10.1 netmask 255.255.255.0 partner 192.168.11.1
ifgrp favor e3b
ifconfig Trunk10-10 up
</pre>
<p>This is how the NICs are configured on the second controller.</p>
<pre class="brush: bash; title: ; notranslate">
ifconfig e3a down
ifconfig e3b down
ifgrp create single Trunk11 e3a e3b
vlan create Trunk11 11
ifconfig Trunk11-11 192.168.11.1 netmask 255.255.255.0 partner 192.168.10.1
ifgrp favor e3a
ifconfig Trunk11-11 up
</pre>
<p>If you need to rebuild the configuration, first delete the vlan, and then destroy the group.</p>
<pre class="brush: bash; title: ; notranslate">
ifconfig Trunk10-10 down
vlan delete Trunk10 10
ifgrp destroy Trunk10
</pre>
<p>To see the config, execute <strong>ifconfig –a</strong>.</p>
<h1>Virtual Connect configuration</h1>
<p>The Virtual Connect module can be managed from http://<<em>IP_of_the_Virtual_Connect</em>><br />
There are two Shared External Uplink Sets defined.</p>
<ul>
<li>ENCSBP01_10G_NAS10</li>
<li>ENCSBP01_10G_NAS11</li>
</ul>
<p>If these sets need to be recreated, follow the screenshots below. This means that ports x7 from both VC1 (Bay 1) and VC2 (Bay 2) are defined as one external network card. The same applies for ports x8.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-02.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-02.png" alt="" width="624" height="350" class="aligncenter size-full wp-image-6225" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-02.png 624w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-02-300x168.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-02-585x328.png 585w" sizes="(max-width: 624px) 100vw, 624px" /></a><br />
<a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-03.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-03.png" alt="" width="624" height="355" class="aligncenter size-full wp-image-6226" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-03.png 624w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-03-300x171.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-03-585x333.png 585w" sizes="(max-width: 624px) 100vw, 624px" /></a><br />
In addition to the Shared Uplink Sets, there are two networks defined.</p>
<ul>
<li>ENCSBP01_iSCSI_NAS10</li>
<li>ENCSBP01_iSCSI_NAS11</li>
</ul>
<p>The first network is associated with the first Shared Uplink Set and External VLAN ID 10, the second network is associated with the second Shared Uplink Set and External VLAN ID 11. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-04.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-04.png" alt="" width="624" height="288" class="aligncenter size-full wp-image-6227" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-04.png 624w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-04-300x138.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-04-585x270.png 585w" sizes="(max-width: 624px) 100vw, 624px" /></a><br />
<a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-05.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-05.png" alt="" width="624" height="289" class="aligncenter size-full wp-image-6228" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-05.png 624w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-05-300x139.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-05-585x271.png 585w" sizes="(max-width: 624px) 100vw, 624px" /></a></p>
<p><strong>NOTE: It is important to match the VLAN IDs (10 and 11) on the NetApp controller and the networks defined in Virtual Connect.</strong> </p>
<p>Finally, when creating a profile for a server (ESXi or Windows), the following NICs should be assigned.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-06.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-06.png" alt="" width="624" height="322" class="aligncenter size-full wp-image-6229" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-06.png 624w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-06-300x155.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-06-585x302.png 585w" sizes="(max-width: 624px) 100vw, 624px" /></a><br />
This means, that the first/second NIC are on VLAN21 from a different Shared Uplink Set. NIC from 3 to 6 are the ones used for iSCSI, and the last two NICs are used for the old iSCSI configuration and VLAN22 servers. Make sure that NICs 1 and 2 and 7 and 8 are set as CUSTOM port speed of 1Gb. That way, we’ll increase the iSCSI (NICs 3-6) to 4Gb.</p>
<h1>MS Windows configuration</h1>
<p>Depending on the subnet that MS Windows is going to use for a public IP, use NIC1 and NIC2 if the server is going to be on the 128.202.21.0/24 subnet and NIC7 and NIC8 if the server is going to be on the 128.202.22.0/24 subnet. These NIC pairs should be teamed using the provided HP Network Team Configuration utility. Your IP subnets may vary.</p>
<p>When dealing with MS Windows, it is unclear what NIC under Network Connections corresponds to the NICs under Virtual Connect (see previous screenshot). </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-07.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-07.png" alt="" width="613" height="334" class="aligncenter size-full wp-image-6230" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-07.png 613w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-07-300x163.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-07-585x319.png 585w" sizes="(max-width: 613px) 100vw, 613px" /></a><br />
In order to identify them we need to use ipconfig /all in Windows and then go to <em>https://Chassis_IP</em>, select the server name from the Device Bays on the left and click on the information tab.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-08.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-08.png" alt="" width="631" height="561" class="aligncenter size-full wp-image-6231" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-08.png 631w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-08-300x267.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-08-585x520.png 585w" sizes="(max-width: 631px) 100vw, 631px" /></a><br />
Based on this information, you can map the NICs.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-09.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-09.png" alt="" width="750" height="177" class="aligncenter size-full wp-image-6232" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-09.png 750w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-09-300x71.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-09-585x138.png 585w" sizes="(max-width: 750px) 100vw, 750px" /></a><br />
If we look at the screenshot from the Virtual Connect server profile, we need to team:</p>
<ul>
<li>1A and 2A (LAC 7 and LAC 8 ) for a public NIC on 128.202.21.0/24 network or whatever your public IP for servers is.</li>
<li>1B and 2B (LAC and LAC 2) for iSCSI NIC team on the first NetApp controller</li>
<li>1C and 2C (LAC 3 and LAC 4) for iSCSI NIC team on the second NetApp controller</li>
<li>1D and 2D (LAC 5 and LAC 6) for another IP subnet that you might use</li>
</ul>
<h1>ESX/ESXi configuration</h1>
<p>When building an ESXi host, follow the screenshots below. vmnic0 and vmnic1 should be used for the Management Network and VM NET 21 network (servers with IP range 128.202.21.0/24) or whatever your IP subnet for servers is.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-10.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-10.png" alt="" width="438" height="533" class="aligncenter size-full wp-image-6233" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-10.png 438w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-10-247x300.png 247w" sizes="(max-width: 438px) 100vw, 438px" /></a><br />
The iSCIS NICs are vmnic2, vmnic3 for the first controller and vmnic4, vmnic5 for the second controller. They MUST be in active/standby mode, otherwise the connection won’t work.<br />
In addition, the Network Failoved Detection MUST be set to Beacon probing for both vSwitch1 and vSwitch2, otherwise the failover won’t work.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-11.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-11.png" alt="" width="512" height="398" class="aligncenter size-full wp-image-6234" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-11.png 512w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-11-300x233.png 300w" sizes="(max-width: 512px) 100vw, 512px" /></a></p>
<h1>Troubleshooting failover</h1>
<p>The easiest way to validate the failover is to simulate a Virtual Connect crash. For that reason, we’ll ping constantly the first and the second controller&#8217;s IP for iSCSI (192.168.10.1 and 192.168.11.) and unplug both cables from VC2 module. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2012/12/P025-12.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2012/12/P025-12.png" alt="" width="605" height="541" class="aligncenter size-full wp-image-6235" srcset="https://blog.andreev.it/wp-content/uploads/2012/12/P025-12.png 605w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-12-300x268.png 300w, https://blog.andreev.it/wp-content/uploads/2012/12/P025-12-585x523.png 585w" sizes="(max-width: 605px) 100vw, 605px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2012/12/netapp-virtual-connect-connect-without-a-switch/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>General: Tips &#038; Tricks and one-liners (Part II)</title>
		<link>https://blog.andreev.it/2011/12/mysql-backup-restore-a-database/</link>
					<comments>https://blog.andreev.it/2011/12/mysql-backup-restore-a-database/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Tue, 27 Dec 2011 19:39:15 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=203</guid>

					<description><![CDATA[Part I, Part III, Part IV. Log with SSH keys only Create the keys&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p><a href="https://blog.andreev.it/?p=134" rel="noopener noreferrer" target="_blank">Part I</a>, <a href="https://blog.andreev.it/?p=5117" rel="noopener noreferrer" target="_blank">Part III</a>, <a href="https://blog.andreev.it/?p=9343" rel="noopener noreferrer" target="_blank">Part IV.</p>
<h1>Log with SSH keys only</h1>
<p>Create the keys and allow it for the username test.</p>
<pre class="brush: bash; title: ; notranslate">
ssh-keygen -t rsa
ssh-copy-id test@localhost
</pre>
<p>Prevent the password login. Edit /etc/ssh/sshd_config and restart the SSH service.</p>
<pre class="brush: bash; title: ; notranslate">
PasswordAuthentication no
</pre>
<h1>Transfer FSMO roles using PowerShell</h1>
<p>Transfer FSMO roles to the domain controller named DC02.</p>
<pre class="brush: powershell; title: ; notranslate">
Get-ADForest andreev.local | ft DomainNamingMaster, SchemaMaster
Get-ADDomain andreev.local | ft InfrastructureMaster, PDCEmulator, RIDMaster
Import-Module ActiveDirectory
Move-ADDirectoryServerOperationMasterRole -Identity &quot;dc02&quot; –OperationMasterRole DomainNamingMaster,PDCEmulator,RIDMaster,SchemaMaster,InfrastructureMaster
</pre>
<h1>Get the external IP in Windows</h1>
<pre class="brush: powershell; title: ; notranslate">
$wc = new-object System.Net.WebClient
$wc.DownloadString(&quot;https://ip.andreev.it&quot;)
</pre>
<h1>Synchronize domain controllers with external time source (NTP)</h1>
<p>On the PDC of the domain execute:</p>
<pre class="brush: bash; title: ; notranslate">
w32tm /config /manualpeerlist:0.north-america.pool.ntp.org /syncfromflags:manual /reliable:yes /update
net stop w32time
net start w32time
</pre>
<p>where <strong>0.north-america.pool.ntp.org</strong> is the external time source (NTP server). You can check the list of these servers <a href="https://www.ntppool.org/zone/@" rel="noopener noreferrer" target="_blank">here</a>.<br />
On non-PDC domain controllers execute:</p>
<pre class="brush: bash; title: ; notranslate">
w32tm /config /syncfromflags:domhier /update 
net stop w32time
net start w32time
</pre>
<h1>Prevent root login in SSH</h1>
<p>To change this behavior, edit <strong>/etc/ssh/sshd_config</strong> and change from:</p>
<pre class="brush: bash; title: ; notranslate">
#PermitRootLogin yes
</pre>
<p>to -></p>
<pre class="brush: bash; title: ; notranslate">
PermitRootLogin no
</pre>
<p>Now, restart the sshd daemon and log remotely using a regular user and then <strong>su &#8211;</strong> to switch to root. </p>
<h1>Get BIOS serial number from command prompt</h1>
<p>Works remotely.</p>
<pre class="brush: plain; title: ; notranslate">
wmic /node:&#x5B;remote computer name] bios get serialnumber
</pre>
<h1>Gnome on OpenBSD 4.2</h1>
<p>Very simple&#8230;</p>
<pre class="brush: bash; title: ; notranslate">
export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/
pkg_add gnome-desktop-2.18.2p0.tgz
pkg_add gnome-session-2.18.2p0.tgz
echo ‘exec gnome-session’ &gt;&gt; ~/.xinitrc
startx
</pre>
<h1>Text/CSV file – Delete lines based on a value</h1>
<p>I made a PowerShell script that scanned multiples subnets and generated about 130,000 lines of text. About 120,000 of these lines were not needed. Because the output was a CSV file, it was logical that I use Excel to delete these lines. But the <a href="http://superuser.com/questions/324377/how-to-automatically-delete-rows-in-excel-2007-based-on-cell-value" target="_blank" rel="noopener noreferrer">macro </a>that I used took forever and after one hour, it just stopped working. CSV is a text file, so I used <a href="https://notepad-plus-plus.org/" target="_blank" rel="noopener noreferrer">Notepad++</a> to edit the file.<br />
In order to delete the whole line that contained &#8220;NO RESPONSE&#8221; (in my case), I used <strong>Edit | Replace </strong>or <strong>Ctrl-H</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2011/12/P012-01.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2011/12/P012-01.png" alt="" width="567" height="336" class="aligncenter size-full wp-image-6127" srcset="https://blog.andreev.it/wp-content/uploads/2011/12/P012-01.png 567w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-01-300x178.png 300w" sizes="(max-width: 567px) 100vw, 567px" /></a><br />
This replacement will delete all lines that contain the string &#8220;NO RESPONSE&#8221;. The syntax is <strong>^.*YOUR_STRING.*$ </strong>and do not put nothing for <strong>&#8220;Replace with:&#8221; </strong>value. Make sure <strong>&#8220;Regular expression&#8221;</strong> is selected. The only problem is that these lines will be gone, but you&#8217;ll have empty lines now. In order to get rid of these lines, head to TextFX home page at <a href="http://sourceforge.net/projects/npp-plugins/files/TextFX/TextFX%20v0.26/" target="_blank" rel="noopener noreferrer">SourceForge</a>. Download this Notepad++ plugin, unzip the archive and put the DLL under <strong>C:\Program Files\Notepad++\plugins</strong> folder. Once you restart Notepad++, you&#8217;ll see a new menu called&#8230;TextFX. Select everything (<strong>Ctrl-A</strong>), then <strong>TextFX | TextFX Edit | Delete blank lines</strong>.</p>
<h1>Upgrading VMware Tools fails on Windows Server 2008 with the message “Error 1316. A network error occured while attempting to read from the file C:\Windows\Installer\VMware Tools.msi”</h1>
<p>I cloned one VM from an ESXi 4.0 host to an ESXi 5.0 U1. When I tried to upgrade the VM tools (interactively), I got an error saying <em>&#8220;Error 1316. A network error occured while attempting to read from the file C:\Windows\Installer\VMware Tools.msi&#8221;</em>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2011/12/P012-02.jpg"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2011/12/P012-02.jpg" alt="" width="405" height="133" class="aligncenter size-full wp-image-6128" srcset="https://blog.andreev.it/wp-content/uploads/2011/12/P012-02.jpg 405w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-02-300x99.jpg 300w" sizes="(max-width: 405px) 100vw, 405px" /></a><br />
At this point, just click OK, open a command prompt with Administrator&#8217;s privileges and type:</p>
<pre class="brush: plain; title: ; notranslate">
C:\users\username&gt; D:
D:&gt; setup /c
</pre>
<p>This command will delete some orphaned registry entries and after the command completes, which is less then a second, just do your standard VM tools upgrade by double-clicking the setup.exe icon.</p>
<p>Source: <a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&#038;cmd=displayKC&#038;externalId=1012693" title="VMware KB 1012693">VMware KB 1012693</a></p>
<h1>Fedora 18: Configure Wireless on Latitude E6400</h1>
<p>I&#8217;ve installed the latest Fedora 18 64-bit on Dell Latitude E6400, but the wireless wasn&#8217;t working. After some research, I&#8217;ve found this <a href="http://forum.fedoraforum.org/showthread.php?t=239922" target="_blank" rel="noopener noreferrer">website</a> that explains how to install the drivers. In my case it was simple:</p>
<pre class="brush: plain; title: ; notranslate">
yum install kmod-wl
service NetworkManager restart
</pre>
<p>Of course, you need a wired connection to do that, othwerise you have to manually transfer the files manually. In addition, if downloading the dependency files is extremely slow, cancel the install and do:</p>
<pre class="brush: plain; title: ; notranslate">
yum install yum-plugin-fastestmirror
</pre>
<h1>Find MAC address for the iLO NIC adapter</h1>
<p>ssh to the iLO&#8217;s IP address and do:</p>
<pre class="brush: bash; title: ; notranslate">
show /map1/enetport1
</pre>
<p>This is how the output looks like.</p>
<pre class="brush: bash; title: ; notranslate">
status=0
status_tag=COMMAND COMPLETED


/map1/enetport1
  Targets
    lanendpt1
  Properties
    Autosense=yes
    PermanentAddress=00:1a:4b:e6:b0:ea
    LinkTechnology=Ethernet
    Speed=100 Mbits/s
    SystemName=your_host_name
    FullDuplex=yes
  Verbs
    cd version exit show set
</pre>
<h1>Windows 2012R2 Upgrade fails with CRITICAL_STRUCTURE_CORRUPTION</h1>
<p>I had to upgrade a Windows 2008R2 server to Windows 2012R2. The server was a VM running on a ESXi 5.0 Update 1 host. The upgrade failed with <strong>CRITICAL_STRUCTURE_CORRUPTION</strong> error. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2011/12/P012-03.jpg"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2011/12/P012-03.jpg" alt="" width="814" height="228" class="aligncenter size-full wp-image-6129" srcset="https://blog.andreev.it/wp-content/uploads/2011/12/P012-03.jpg 814w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-03-300x84.jpg 300w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-03-768x215.jpg 768w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-03-585x164.jpg 585w" sizes="(max-width: 814px) 100vw, 814px" /></a></p>
<p>The solution is to upgrade the ESXi host first to ESXi 5.0 Update 3 or use this workaround as described <a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&#038;cmd=displayKC&#038;externalId=2060019" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p>1.Power down the virtual machine.<br />
2.Right-click the virtual machine.<br />
3.Click Edit Settings.<br />
4.Click the Options tab.<br />
5.Select CPUID Mask under Advanced.<br />
6.Click Advanced.<br />
7.Under the Register column, locate the edx register under Level 80000001.<br />
8.Paste this into the Value field:</p>
<pre class="brush: bash; title: ; notranslate">
----:0---:----:----:----:----:----:----
</pre>
<p>9.Click OK.<br />
10.Click OK to close the virtual machine properties. </p>
<h1>Run PowerShell script as a scheduled task that uses Excel COM object</h1>
<p>I made a small PowerShell script that reads an Excel file from SharePoint, converts it to CSV and does some calculations. The script was working fine, but when I tried to run the script as a scheduled task, the Excel->CSV conversion never happened. This is part of the code.</p>
<pre class="brush: powershell; title: ; notranslate">
# Converts the Excel file. Excel must be installed. The output is MASTER-INVENTORY.csv
$xlCSV=6
$Excelfilename = $Path
$CSVfilename = &quot;C:\Scripts\CheckIfBackupExists\MASTER-INVENTORY.csv&quot;
$Excel = New-Object -comobject Excel.Application
$Excel.Visible = $False
$Excel.displayalerts=$False
$Workbook = $Excel.Workbooks.Open($ExcelFileName)
$Workbook.SaveAs($CSVfilename,$xlCSV)
$Excel.Quit()
If(ps excel){kill -name excel}
</pre>
<p>This code never executed properly when scheduled. I&#8217;ve found <a href="http://social.technet.microsoft.com/Forums/windowsserver/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell" target="_blank" rel="noopener noreferrer">this</a> solution to be the simplest.</p>
<p>For a 32 bit OS, create a folder called <em><strong>c:\Windows\System32\config\systemprofile\Desktop </strong></em>and for a 64-bit OS create both <em><strong>c:\Windows\System32\config\systemprofile\Desktop </strong></em>and <em><strong>c:\Windows\SysWOW64\config\systemprofile\Desktop</strong></em>.</p>
<h1>Send SNMP trap to HP-SIM from command prompt</h1>
<p>From time to time <a title="HP-SIM" href="http://h18013.www1.hp.com/products/servers/management/hpsim/index.html?jumpid=go/hpsim" target="_blank" rel="noopener noreferrer">HP-SIM</a> stops working and the only way to resolve this issue is to restart the HP-SIM service. In order to know when that&#8217;s going to happen, I am using this scheduled script to send a test trap to HP-SIM. If HP-SIM is properly configured, it will send an e-mail with &#8220;Generic Trap&#8221; in the subject. If something is wrong with HP-SIM, you won&#8217;t receive this email, which means it&#8217;s time to restart the HP-SIM service.</p>
<p>First, download trapgen from <a title="TrapGen" href="http://downloadmyfilesnow.us/download-trapgen-for-windows.html" target="_blank" rel="noopener noreferrer">here</a>. Then execute this command.</p>
<pre class="brush: plain; title: ; notranslate">C:\&gt; trapgen -d &lt;servername&gt; -c public -o 1.3.6.1.4.1.232 -g 6 -s 11003</pre>
<p>If everything works fine, you can create a batch file and then do your scheduling tasks.</p>
<h1>Power on/off HP servers remotely using plink</h1>
<p>To be able to change the power state of the servers, we&#8217;ll use <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank" rel="noopener noreferrer">plink</a>. <strong>plink </strong>allows you to SSH to the server and send a command, the one that you usually type in. </p>
<p>So, it&#8217;s really simple, just create a batch file and add one or more of these commands for multiple servers.</p>
<pre class="brush: bash; title: ; notranslate">
plink -pw ilo_pwd &quot;ilo_username@ilo_ip_or_hostname&quot; &quot;power on&quot;
</pre>
<p>or</p>
<pre class="brush: bash; title: ; notranslate">
plink -pw ilo_pwd &quot;ilo_username@ilo_ip_or_hostname&quot; &quot;power off&quot;
</pre>
<p>where <strong>ilo_pwd</strong> and <strong>ilo_username</strong> are the credentials that you use to log to iLO GUI and <strong>ilo_ip_or_hostname</strong> is the IP or the hostname of the iLO.</p>
<p><strong>NOTE</strong>: The power off command will do hard power off, so the OS running won&#8217;t be aware of that. Make sure the OSes are properly shut down to avoid any corruption. </p>
<h1>Powershell: Change SNMP settings on a remote server</h1>
<p>Recently, I built a new HP-SIM server and I had to change the SNMP settings on 1000+ servers to send the traps to a new destination. Here is a script that I made. It should be self-explanatory. </p>
<pre class="brush: bash; title: ; notranslate">
# Powershell to configure SNMP - K.Andreev 20141117
# Usage: ./SetSNMP.ps1 -server &lt;server_name&gt; -community &lt;community_string&gt; -target &lt;target_hostname&gt; -test $true/$false
# Adds target_hostname as a SNMP target, community_string as SNMP string on the server server_name
# If parameter -test is $true, nothing is added to the registry. If you ommit the parameter, nothing is added as well

param(
&#x5B;string]$server = &quot;&quot;,
&#x5B;string]$community = &quot;&quot;,
&#x5B;string]$target = &quot;&quot;,
&#x5B;bool]$test = $true
)

if (($server -eq &quot;&quot;) -or ($community -eq &quot;&quot;) -or ($target -eq &quot;&quot;)){
	Write-Host &quot;-------------------------------&quot;
	Write-Host &quot;Kliment Andreev - November 2014&quot;
	Write-Host &quot;-------------------------------&quot;
	Write-Host &quot;Usage: ./SetSNMP.ps1 -server &lt;server_name&gt; -community &lt;community_string&gt; -target &lt;target_hostname&gt; -test true/false&quot;
	Write-Host &quot;Adds target_hostname as a SNMP target, community_string as SNMP string on the server server_name&quot;
	Write-Host &quot;If parameter -test is $true, nothing is added to the registry&quot;
	Write-Host &quot;&quot;
	exit
}
try {
	$check = Get-WMIObject Win32_Service -ComputerName $server -ErrorAction Stop | Where-Object {$_.name -eq &quot;SNMP&quot;}
}
catch {
	$Exception = $_
    Write-Host &quot;SNMP not installed on&quot; $server &quot;, exception: $($_.Exception.Message)&quot; -ForegroundColor Red
}
if ($check.Status -eq &quot;OK&quot;) {
	Write-Host &quot;SNMP installed on&quot; $server&quot;, proceeding with configuration...&quot; -ForegroundColor Green
	$objReg = &#x5B;Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(&#039;LocalMachine&#039;, $server)
	
	# Tab Security, Accept SNMP packets from these hosts
	Write-Host &quot;Accept packets from these hosts:&quot; -ForegroundColor Yellow
	$Values_counter = 1
	$objRegKeyPM = $objReg.OpenSubKey(&quot;SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\PermittedManagers&quot;,$true)
	$Duplicate = $false
	while ($true) {
		$value = $objRegKeyPM.GetValue($Values_counter.ToString())
		if ($value -eq $target) {
			$Duplicate = $true
			}
		if ($value -eq $null) {break}
		Write-Host `t $value -ForegroundColor White
		$Values_counter++
	}
	if (!$Duplicate) {
		Write-Host &quot;===&gt; Adding&quot; $Values_counter $target &quot;to HKLM\..\SNMP\Parameters\PermittedManagers&quot;-ForegroundColor Green
		if (!$test) {$objRegKeyPM.SetValue($Values_counter.ToString(), $target)}
		} else {
		Write-Host $target &quot;already exists.&quot; -ForegroundColor Red
		}
	$devnull = $objRegKeyPM.Close
	
	# Tab Security, Accepted Community Names
	Write-Host &quot;Accepted Community Names:&quot; -ForegroundColor Yellow
	$objRegKeyVC = $objReg.OpenSubKey(&quot;SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\ValidCommunities&quot;,$true)
	$Duplicate = $false
	foreach($value in $objRegKeyVC.GetValueNames()){
		Write-Host `t $value, $objRegKeyVC.GetValue($value).ToString()
		if ($value -eq $community){
			$Duplicate = $true
		}
	}
	if (!$Duplicate) {
		Write-Host &quot;===&gt; Adding &quot; $community &quot;to HKLM\..\SNMP\Parameters\ValidCommunities&quot; -ForegroundColor Green
		if (!$test) {$objRegKeyVC.SetValue($community, 8)}
		} else {
		Write-Host $community &quot;already exists.&quot; -ForegroundColor Red
		}
	$devnull = $objRegKeyVC.Close
	
	# Tab Traps, Community Name
	$objRegKeyCN = $objReg.OpenSubKey(&quot;SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\TrapConfiguration&quot;,$true)
	$devnull = $objRegKeyCN.CreateSubKey($community)
	$devnull = $objRegKeyCN.Close
	
	# Tab Traps, Trap Destinations
	Write-Host &quot;Trap destinations:&quot; -ForegroundColor Yellow
	$Values_counter = 1
	$strKey = &quot;SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\TrapConfiguration\\&quot;
	$strKeyTD = $strKey + $community
	$objRegKeyTD = $objReg.OpenSubKey($strKeyTD,$true)
	$Duplicate = $false
	foreach($value in $objRegKeyTD.GetValueNames()){
		$value_name = $objRegKeyTD.GetValue($value).ToString()
		Write-Host `t $value, $value_name
		$Values_counter++
		if ($value_name -eq $target){
			$Duplicate = $true
		}
	}
	if (!$Duplicate) {
		Write-Host &quot;===&gt; Adding&quot; $values_counter $target &quot;to HKLM\..\SNMP\Parameters\TrapConfiguration\&quot;$community -ForegroundColor Green
		if (!$test) {$objRegKeyTD.SetValue($Values_counter.ToString(), $target)}
		} else {
		Write-Host $target &quot;already exists.&quot; -ForegroundColor Red
		}
	$devnull = $objRegKeyTD.Close
	$devnull = $objReg.Close
}
</pre>
<h1>SSH public-key authentication for scp</h1>
<p>I had to copy a file between two hosts using scp and it prompted me for a password. scp does not allow you to specify the password in a command line. So, here is a quick way to establish a trust between two hosts.<br />
<strong>We&#8217;ll assume that user-A on host-A is copying a file to the home folder of user-B on host-B.<br />
</strong><br />
On <strong>host-A</strong>, logged as <strong>user-A</strong> create the private/public key pair.</p>
<pre class="brush: bash; title: ; notranslate">
ssh-keygen
</pre>
<p>You should see something like this. Do not enter a passphrase.</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user-A/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user-A/.ssh/id_rsa.
Your public key has been saved in /home/user-A/.ssh/id_rsa.pub.
The key fingerprint is:
98:c4:fe:aa:ff:aa:bb:11:b4:3b:7a:94:1f:ac:c4:0f user-A@host-A
The key&#039;s randomart image is:
+--&#x5B; RSA 2048]----+
|                 |
|       .  .  . o |
|  AA  . . C . Y  |
|       + =   o o |
|      . X   . o  |
|         . &amp; . . |
|        Y o B o  |
|         + o = . |
|          V . .  |
+-----------------+
</pre>
<p>You&#8217;ll have two files (<strong>/home/user-A/.ssh/id_rsa</strong>) which is your private key and (<strong>/home/user-A/.ssh/id_rsa.pub</strong>) which is your public key. Copy your public key to host-B.</p>
<pre class="brush: bash; title: ; notranslate">
cat ~/.ssh/id_rsa.pub | ssh user-A@host-B &#039;cat &gt;&gt; ~/.ssh/authorized_keys&#039;
</pre>
<p>If you get access denied, just copy <strong>id_rsa.pub</strong> file to the home folder of <strong>user-B</strong> on <strong>host-B</strong> under the <strong>.ssh</strong> folder and append it to the <strong>authorized_keys</strong> file. If this file doesn&#8217;t exist, create it.</p>
<p>Once you are done, you can copy the files from host-A using:</p>
<pre class="brush: bash; title: ; notranslate">
scp somefiles.* user-B@host-B:
</pre>
<h1>PowerShell, plink &#038; HP c7000 chassis</h1>
<p>Recently I was looking for a way to see how much memory I have installed on 16 blades that I have in a HP c7000 chassis. These blades are a mix of Windows and ESXi so a script that would cover both is not feasible. But, HP c7000 has a <a href="http://h20566.www2.hpe.com/hpsc/doc/public/display?docId=c00702815" target="_blank" rel="noopener noreferrer">CLI</a> that allows us to see how much memory each blade has. </p>
<p>We&#8217;ll use <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank" rel="noopener noreferrer">plink</a> to sent this command to the chassis and run the whole thing from PowerShell so we can do string manipulation. </p>
<p>Open PowerShell, make sure that plink is in your PATH or specify the full path to plink and run:</p>
<pre class="brush: bash; title: ; notranslate">
$output = plink -pw &quot;password_for_the_chassis&quot; &quot;username_for_the_chassis@chassis_hostname&quot; &quot;show server info all&quot;
</pre>
<p>If everything is OK, you shouldn&#8217;t see any output. Do:</p>
<pre class="brush: bash; title: ; notranslate">
$output | select-string -pattern &quot;Memory&quot;
</pre>
<p>&#8230; and you should see this. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2011/12/P012-04.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2011/12/P012-04.png" alt="" width="457" height="265" class="aligncenter size-full wp-image-6130" srcset="https://blog.andreev.it/wp-content/uploads/2011/12/P012-04.png 457w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-04-300x174.png 300w" sizes="(max-width: 457px) 100vw, 457px" /></a></p>
<p>&#8230;or try this to see the IP addresses, CPUs, serial numbers etc&#8230;</p>
<pre class="brush: bash; title: ; notranslate">
$output | select-string -pattern &quot;IP Address&quot;
$output | select-string -pattern &quot;CPU&quot;
$output | select-string -pattern &quot;Serial&quot;
$output | select-string -pattern &quot;FlexNIC&quot;
</pre>
<h1>mod_deflate on Apache 2.4</h1>
<p>If you are using WordPress like I do, you&#8217;ll benefit if you have mod_deflate enabled. This module compresses the content that you specify and delivers it to the end user. Same technique as compressing text file using gzip. Apache 2.4 on FreeBSD already comes with mod_deflate precompiled, but it&#8217;s disabled by default.</p>
<p>First, edit <strong>/usr/local/etc/apache24/httpd.conf</strong> and uncomment the following line. </p>
<pre class="brush: plain; title: ; notranslate">
LoadModule deflate_module libexec/apache24/mod_deflate.so
</pre>
<p>Next, make sure that you have the following line in the same <strong>httpd.conf</strong> file. </p>
<pre class="brush: plain; title: ; notranslate">
Include etc/apache24/Includes/*.conf
</pre>
<p>This line enables httpd.conf to span in multiple files, so we can have our mod_deflate config parameters in a separate file. Go to <strong>/usr/local/etc/apache24/Includes</strong> and create a file called <strong>mod_deflate.conf</strong>. Add the following and save.</p>
<pre class="brush: bash; title: ; notranslate">
AddOutputFilterByType DEFLATE text/html text/plain
#Highest 9 - Lowest 1
DeflateCompressionLevel 9

#Optional
#Skip browsers with known problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0&#x5B;678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

#Optional
#Logging
DeflateFilterNote ratio
LogFormat &#039;&quot;%r&quot; %b (%{ratio}n) &quot;%{User-agent}i&quot;&#039; deflate
CustomLog /var/log/deflate_log deflate
</pre>
<p>You can see what each line means, <a href="https://httpd.apache.org/docs/2.4/mod/mod_deflate.html" target="_blank" rel="noopener noreferrer">here</a>. Make sure you don&#8217;t compress JPG, PNG, MP3 or PDF files. These files are already compressed and you&#8217;ll just make your web page load slower.<br />
Restart apache with <strong>apachectl graceful </strong>and that&#8217;s it. If you want to see how much bandwidth you are saving, go to this <a href="http://www.whatsmyip.org/http-compression-test/" target="_blank" rel="noopener noreferrer">page </a>and enter your URL. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2011/12/P012-05.jpg"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2011/12/P012-05.jpg" alt="" width="399" height="155" class="aligncenter size-full wp-image-6131" srcset="https://blog.andreev.it/wp-content/uploads/2011/12/P012-05.jpg 399w, https://blog.andreev.it/wp-content/uploads/2011/12/P012-05-300x117.jpg 300w" sizes="(max-width: 399px) 100vw, 399px" /></a></p>
<h1>git &#8211; quick cheat sheet</h1>
<p>Create a new repo at www.github.com called New-Project or Whatever. Install the git client on your local PC (e.g yum install git for CentOS/RedHat or pkg install git for FreeBSD). Download the client for Windows from https://git-scm.com/.</p>
<p>Once you have your project ready, type</p>
<pre class="brush: plain; title: ; notranslate">
git init
git add .
git commit -m &quot;Final production code&quot;
git remote add origin http://www.github.com/your_username/New-Project
git push origin master
</pre>
<p>If you get an error when you try to push, pull the changes from the master first.</p>
<pre class="brush: plain; title: ; notranslate">
git pull origin master
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2011/12/mysql-backup-restore-a-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>General: Tips &#038; Tricks and one-liners (Part I)</title>
		<link>https://blog.andreev.it/2011/12/prevent-root-login-in-ssh/</link>
					<comments>https://blog.andreev.it/2011/12/prevent-root-login-in-ssh/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Sat, 03 Dec 2011 21:26:30 +0000</pubDate>
				<category><![CDATA[Editor's Pick]]></category>
		<category><![CDATA[General]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=134</guid>

					<description><![CDATA[Part II, Part III, Part IV. MySQL Backup/Restore BACKUP mysqldump -u &#60;username&#62; -p &#60;password&#62;&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p><a href="https://blog.andreev.it/?p=203" rel="noopener noreferrer" target="_blank">Part II</a>, <a href="https://blog.andreev.it/?p=5117" rel="noopener noreferrer" target="_blank">Part III</a>, <a href="https://blog.andreev.it/?p=9343" rel="noopener noreferrer" target="_blank">Part IV.</p>
<h1>MySQL Backup/Restore</h1>
<p><strong>BACKUP</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysqldump -u &lt;username&gt;  -p &lt;password&gt; databasename &gt; /somewhere/dbname.sql
</pre>
<p>Do not leave space between -p and the password.</p>
<p><strong>RESTORE</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql -u &lt;username&gt;  -p   &lt;password&gt; databasename &lt;  /somewhere/dbname.sql
</pre>
<p><strong>CREATE USER/DATABASE and GRANT RIGHTS</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql -u adminusername -p
CREATE USER &#039;custom&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;obscure&#039;;
CREATE DATABASE databasename;
GRANT ALL PRIVILEGES ON databasename.* TO &quot;custom&quot;@&quot;localhost&quot; IDENTIFIED BY &quot;obscure&quot;;
FLUSH PRIVILEGES;
</pre>
<h1>FreeBSD update OS and ports</h1>
<p>To update the OS (not upgrade):</p>
<pre class="brush: plain; title: ; notranslate">
freebsd-update fetch
freebsd-update install
</pre>
<p>To update the ports tree:</p>
<pre class="brush: plain; title: ; notranslate">
portsnap fetch
portsnap update
</pre>
<p>Update the actual ports:</p>
<pre class="brush: plain; title: ; notranslate">
portmaster -a
</pre>
<h1>tail under Windows</h1>
<pre class="brush: powershell; title: ; notranslate">
Get-Content -Path &quot;&lt;drive&gt;:\Folder\FileName.extension&quot; -Wait
</pre>
<h1>tcpdump to monitor HTTP traffic</h1>
<p>1. To monitor HTTP traffic including request and response headers and message body:</p>
<pre class="brush: bash; title: ; notranslate">
tcpdump -A -s 0 &#039;tcp port 80 and (((ip&#x5B;2:2] - ((ip&#x5B;0]&amp;amp;0xf)&lt;&lt;2)) - ((tcp&#x5B;12]&amp;amp;0xf0)&gt;&gt;2)) != 0)&#039;
</pre>
<p>2. To monitor HTTP traffic including request and response headers and message body from a particular source:</p>
<pre class="brush: bash; title: ; notranslate">
tcpdump -A -s 0 &#039;src example.com and tcp port 80 and (((ip&#x5B;2:2] - ((ip&#x5B;0]&amp;amp;0xf)&lt;&lt;2)) - ((tcp&#x5B;12]&amp;amp;0xf0)&gt;&gt;2)) != 0)&#039;
</pre>
<p>3. To monitor HTTP traffic including request and response headers and message body from local host to local host:</p>
<pre class="brush: bash; title: ; notranslate">
tcpdump -A -s 0 &#039;tcp port 80 and (((ip&#x5B;2:2] - ((ip&#x5B;0]&amp;amp;0xf)&lt;&lt;2)) - ((tcp&#x5B;12]&amp;amp;0xf0)&gt;&gt;2)) != 0)&#039; -i lo
</pre>
<p>4. To only include HTTP requests, modify “tcp port 80” to “tcp dst port 80” in above commands</p>
<h1>Get the OU for a user or a computer in PowerShell.</h1>
<pre class="brush: powershell; title: ; notranslate">
$comp=Get-ADComputer -identity &lt;computer_name&gt; -properties CanonicalName
</pre>
<pre class="brush: powershell; title: ; notranslate">
$user=Get-ADUser -identity &lt;user_name&gt; -properties CanonicalName
</pre>
<h1>Send e-mail using Python and AWS SES</h1>
<p>Create an index.html file in the same directory where this script will reside called index.html. That will be the body of your e-mail.<br />
In my case index.html looks like this.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;h1&gt;Hello!&lt;/h1&gt;
</pre>
<p>You can comment line #24 below if you don&#8217;t want to see the debug output. I suggest you leave it as is.</p>
<pre class="brush: python; title: ; notranslate">
import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

fromaddr = &quot;no-reply@somedomain.com&quot;
toaddr = &quot;kliment.andreev@whatever.com&quot;
EMAIL_HOST = &#039;email-smtp.us-east-1.amazonaws.com&#039;
EMAIL_HOST_USER = &#039;AKIAJUEQQ7DIHJUCKAVA&#039;
EMAIL_HOST_PASSWORD = &#039;AlRPmyef-qAkajSzCtn43YY447rFlJ8GXCBMWyaNide&#039;
EMAIL_PORT = 587

msg = MIMEMultipart(&#039;alternative&#039;)
msg&#x5B;&#039;Subject&#039;] = &quot;AWS TEST&quot;
msg&#x5B;&#039;From&#039;] = fromaddr
msg&#x5B;&#039;To&#039;] = toaddr

html = open(&#039;index.html&#039;).read()

mime_text = MIMEText(html, &#039;html&#039;)
msg.attach(mime_text)

s = smtplib.SMTP(EMAIL_HOST, EMAIL_PORT)
s.set_debuglevel(10)
s.starttls()
s.login(EMAIL_HOST_USER, EMAIL_HOST_PASSWORD)
s.sendmail(fromaddr, toaddr, msg.as_string())
s.quit()
</pre>
<p>If you want to send to multiple recipients, replace the lines #7 and #27 to look like this.</p>
<pre class="brush: python; title: ; notranslate">
toaddr = &quot;kliment.andreev@domain1.com,klimenta@domain2.com,kandreev@domain3.com&quot;
s.sendmail(fromaddr, msg&#x5B;&#039;To&#039;].split(&#039;,&#039;), msg.as_string())
</pre>
<h1>Display remote SSL certificate</h1>
<pre class="brush: bash; title: ; notranslate">
echo | openssl s_client -showcerts -servername blog.andreev.it -connect blog.andreev.it:443 2&gt;/dev/null | openssl x509 -inform pem -noout -text
</pre>
<h1>Windows DNS server &#8211; clear cache</h1>
<p>From an elevated cmd prompt</p>
<pre class="brush: bash; title: ; notranslate">
dnscmd /clearcache
</pre>
<h1>List public IP addresses associated with an instance in AWS</h1>
<pre class="brush: bash; title: ; notranslate">
aws ec2 describe-instances --query &quot;Reservations&#x5B;*].Instances&#x5B;*].PublicIpAddress&quot; --output=text
</pre>
<h1>RHEL\CentOS 7: Limit SSH to specific IPs</h1>
<p>I have a CentOS VM that&#8217;s running behind a pfSense firewall and a NAT rule that forwards all SSH traffic to this VM. So, pretty much my VM is exposed to the public. I saw a lot of scripts trying to penetrate so what I did is, I used the <strong>firewalld </strong>service to restrict SSH to specific IPs. Make sure that you have <strong>firewalld </strong>enabled and running.</p>
<pre class="brush: bash; title: ; notranslate">
systemctl status firewalld
</pre>
<p>Now, add the trusted IPs or ranges. In my case my home network range and a single public IP.</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --zone=&quot;trusted&quot; –-add-source=192.168.1.0/24
firewall-cmd --zone=&quot;trusted&quot; –-add-source=11.12.99.88
</pre>
<p>Add the SSH service to the trusted zone.</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --zone=&quot;trusted&quot; –add-service=ssh
</pre>
<p>Check if everything is OK</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --zone=&quot;trusted&quot; –list-all
</pre>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd –-zone=public –remove-service=ssh
</pre>
<p>Try to access your server from some other IP and you&#8217;ll see you are blocked. In order for these changes to be permanent, you&#8217;ll have to execute all these commands again with the <strong>&#8211;permanent</strong> option.</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --zone=&quot;trusted&quot; –-add-source=192.168.1.0/24 --permanent
firewall-cmd --zone=&quot;trusted&quot; –-add-source=11.12.99.88 --permanent
firewall-cmd --zone=&quot;trusted&quot; –add-service=ssh --permanent
firewall-cmd –-zone=public –remove-service=ssh --permanent
</pre>
<p>Now, the changes will stay across reboots. You can use the same scenario for other services as well.</p>
<h1>Download Oracle JRE from command prompt</h1>
<p>Go to the <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" rel="noopener noreferrer" target="_blank">download </a>page and find the archive that you want to download. Click to accept the agreement and then get the URL of the archive.</p>
<pre class="brush: bash; title: ; notranslate">
wget --header &quot;Cookie: oraclelicense=accept-securebackup-cookie&quot; &lt;URL&gt;
</pre>
<h1>Convert MP3 files to Ogg-Vorbis using sox in all subfolders</h1>
<pre class="brush: bash; title: ; notranslate">
find . -name &#039;*.mp3&#039; -exec bash -c &#039; sox -V3 &quot;$1&quot; &quot;${1%.mp3}.ogg&quot;&#039; -- {} \;
</pre>
<p>Delete all mp3 files after.</p>
<pre class="brush: bash; title: ; notranslate">
find . -name &quot;*.mp3&quot; -exec rm {} \;
</pre>
<h1>Extract a tar archive (tarball) without the head/container directory (folder)</h1>
<p>You have a tarball aaa.tar.gz with the following structure.<br />
<aaa><br />
&#8212;-file1.txt<br />
&#8212;-file2.txt<br />
You want to extract the files to a directory without the top aaa folder.</p>
<pre class="brush: bash; title: ; notranslate">
tar xzvf aaa.tar.gz --strip 1 -C destination_folder
</pre>
<p></aaa></p>
<h1>Samba 4.x, list Windows share, mount Windows share</h1>
<pre class="brush: plain; title: ; notranslate">
sudo mount.cifs -v -o username=my_username,domain=netbios_domain_name,vers=2.1 //host.domain.local/share /mnt
</pre>
<p>If you are unable to write to the mounted folder, specify the user as -o&#8230;vers=2.1,uid=4801105,gid=4800513 which is a user that has rights to that share.</p>
<pre class="brush: plain; title: ; notranslate">
smbclient //host.domain.local/share -U my_username@domain.local -m SMB3 -W netbios_domain_name
</pre>
<h1>Speed up video files x30</h1>
<pre class="brush: bash; title: ; notranslate">
ffmpeg -i input.mov -vf &quot;setpts=(PTS-STARTPTS)/30&quot; -crf 18 output.mov
</pre>
<h1>Replace pattern in file names</h1>
<p>E.g. You want to remove [BBB] from these files 123[BBB]aaa.txt and asd[BBB]123.txt.</p>
<pre class="brush: powershell; title: ; notranslate">
Get-ChildItem *.txt | ForEach { Move-Item -LiteralPath $_.Name $_.Name.Replace(&quot;&#x5B;BBB]&quot;, &quot;&quot;) }
</pre>
<h1>PowerShell &#8211; create TCP listener</h1>
<pre class="brush: powershell; title: ; notranslate">
$Listener = &#x5B;System.Net.Sockets.TcpListener]9999;
$Listener.Start();
# Test the port with telnet
# once completed execute below
$Listener.Stop();
</pre>
<h1>Get the model name of the computer from BIOS</h1>
<pre class="brush: bash; title: ; notranslate">
wmic csproduct get name
</pre>
<h1>uptime in Windows</h1>
<p>Download the zipped EXE <a href="https://blog.andreev.it/wp-content/uploads/2011/12/uptime.zip" rel="noopener noreferrer" target="_blank">here</a>. MD5: e37822139136b6296bc58617fceb010d. Source in C.</p>
<pre class="brush: cpp; title: ; notranslate">
// uptime - shows the uptime on a Windows system
// K.Andreev - 20180803 - BSD Simplified License

#include &quot;stdafx.h&quot;
#include &lt;Windows.h&gt;

int main()
{
DWORD dMilliseconds = GetTickCount();
DWORD dDays = dMilliseconds / 86400000;
DWORD dHours = dMilliseconds / 3600000 - dDays * 24;
DWORD dMinutes = dMilliseconds / 60000 - dHours * 60 - dDays * 1440;
DWORD dTemp = dDays * 86400 - dHours * 3600 - dMinutes * 60;
DWORD dSeconds = dMilliseconds / 1000 - dDays * 86400 - dHours * 3600 - dMinutes * 60;

if (dDays != 0) {
printf(&quot;up %d days, %d hours, %d minutes, %d seconds&quot;, dDays, dHours, dMinutes, dSeconds);
return 0;
}
if (dHours != 0) {
printf(&quot;up %d hours, %d minutes, %d seconds&quot;, dHours, dMinutes, dSeconds);
return 0;
}
if (dMinutes != 0) {
printf(&quot;up %d minutes, %d seconds&quot;, dMinutes, dSeconds);
return 0;
}
printf(&quot;up %d seconds&quot;, dSeconds);

return 0;
}
</pre>
<h1>Replace CRLF in a file, DOS 2 UNIX text format</h1>
<pre class="brush: bash; title: ; notranslate">
sed -i &#039;s/\r//g&#039; /tmp/script.sh
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2011/12/prevent-root-login-in-ssh/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
