Browsed by
Category: IT

How to copy a file in Vi

How to copy a file in Vi

There was a joke who spread at one moment, regarding how to generate secure passwords and it was something like this:

“Want to generate a secure password?..take a developer inside Vim and ask him to exit”

It goes without saying that Vi or Vim are text editors which are used quite often on Linux servers and with Cloud Computing nowadays being pretty much the norm, a lot more people interact with those machines in one way or another. 

So here I am in the shoes of the previous developer trying to copy a configuration file from one machine to another. I have a “black belt” in googling stuff but a white one in Vi so “how to select everything in Vi” returns the ggVG combination.

Since I actually needed to copy to clipboard and the length of the config file was longer than what my screen was able to show, it only produced “undesirable” (not all the lines) content.

For those in need of something similar and want to copy the entire content of a file in vi/vim there is an workaround/think outside the box approach:

Don’t use Vi/Vim, use the cat command and select the content using the mouse. Or at least this approach worked for me.

Windows 10 SSH

Windows 10 SSH

Microsoft Windows has come a long way since 95 and I think Windows 10 is the best iteration, with this one going the “as a service” implementation route. To cut to the chase if you are someone who has to use SSH to connect to servers you can now do it natively from inside PowerShell or CMD. (I know, I know, PuTTY is always there to save the day 😛 )

To check if the computer has the version of Windows 10 which already has the SSH client configured, all you have to do is type “ssh” inside PowerShell and if you see the same output as in the image below you are good to go!

In a real world scenario, if you want to connect to a Virtual Machine, say an EC2 Instance in AWS, you will have to meet two conditions:

  1. Make sure that the key you have is in OpenSSH format (puTTYgen to the rescue in case you want to convert a ppk)

2. Make sure that the key file has the appropriate permissions. To do this from the ui you can follow these steps

Right click on the file->Go to Security->Advanced->Disable inheritance-> Select the first option “Convert inherited permissions…”-> Remove all the other accounts that you find in the permissions tab and only leave the account that you use. Make sure that the same account is the owner of the file.

How do I ?

How do I ?

My code editor of choice is Visual Studio Code and so far I found it very useful. It also has a PowerShell extension so I can run my scripts directly from within the Code Editor.

VS Code has a lot of themes from which you can choose but I prefer one theme for the editor and the classic blue and white theme for the terminal.

So if you are like me, you can quickly change the aspect of the terminal by:

  • Open the User Settings (Ctrl + , )
  • Go to Workbench->Appearance->Color Customization and click on “Edit in settings.json
  • Add the code below:
workbench.colorCustomizations": {
    "terminal.foreground": "#FFFFFF",
    "terminal.background": "#012456"

Office 365 tip of the day

Office 365 tip of the day

As an “IT Firefighter” there comes a time when you have to recreate an Outlook profile. In Office 365, the default behaviour for Microsoft Outlook is to run in “Cached Exchange Mode” and only download emails which are 1 year old, however, if you have a large mailbox, it can take hours until Outlook’s status becomes “All folders are up to date”.

While the update process is running and emails are getting downloaded, new emails might not show up in inbox so in order to slightly improve the update process you can:

  • Go to “Send / Receive” and click on “Work Offline” button , wait a second and click back on it. (This will trigger the download process and get the latest emails from the mailbox.) These steps should be repeated every time you want to get the newest emails until, status is “All folders are up to date”

The calendar might be the last one to update so to force the download of the latest meeting you can:

  • Click on the calendar icon
  • Go to “Send / Receive” and click “Update Folder”

Another workaround is to just use Outlook Web App while Outlook downloads the emails.

Peace Out!

Create a VPN Connection and change its settings with PowerShell. Windows 10

Create a VPN Connection and change its settings with PowerShell. Windows 10

I had to deploy a VPN connection in an environment which looks like this:

  • Domain Controller is hosted on a Virtual Machine in Azure
  • Using an Azure Virtual Network Gateway
  • Point-to-site configuration uses RADIUS authentication.

I accomplished this using the Windows administrator’s best friend, PowerShell.

The prerequisites for these are:

  • Get the VPN server IP/DNS
  • Make sure computers are using PowerShell 3.0

The Powershell script to deploy a VPN connection would look like this:

#Set Variables for the VPN connection
$VPNconnectionName = "New VPN"
$SRVaddress = ""
$dnssuf = ""

#Create the VPN connection
Add-VpnConnection -Name $VPNconnectionName -ServerAddress $SRVaddress -TunnelType Sstp -AuthenticationMethod Eap -EncryptionLevel Required -AllUserConnection -SplitTunneling -IdleDisconnectSeconds 900 -DnsSuffix $dnssuf

#Get the content from the phone book
$contain = Get-Content -Path "$env:ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk" -Raw

#Change the connection phone book content to add the internal DNS entries  
if ($contain.Contains("IpDnsAddress=")){
($contain) -replace 'IpDnsAddress=','IpDnsAddress=' -replace 'IpDns2Address=','IpDns2Address='-replace 'IpNameAssign=1','IpNameAssign=2'| Set-Content "$env:ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk"

Hey can you help me? #1

Hey can you help me? #1

Professionally I’ve been a SysAdmin ( IT firefighter focused ) and I still think I didn’t hear/see them all, also I want to share with you, brief funny experiences.

And without further ado, this is me, one day when a workplace proximity acquaintance(WPA) comes to my desk and:

WPA: Hey can you help me with my screen?

IT Firefighter: Sure, what is the problem?

WPA: Bla bla bla bla ….bla (lots of “complex” things which don’t make sense)

IT Firefighter: OK, let’s to go to your desk and see what is wrong!


Here we are in front of the computer and the WPA explains that a program looks like it is running but it does not appear on the screen.

WPA has two screens and this time, only one was turned on!…what do you think?

Problem solved by pressing the power button on the second screen where the orphan program was chilling on the desktop 🙂



AWS Transformation Day

AWS Transformation Day

Some perks of living in a big city are that, from time to time, you can attend nice events for free. I went to AWS Transformation DAY to get a sneak peek into the Public Cloud world.

The Good

  • The Keynote speaker delivered a good presentation and the audience appeared to be satisfied, he even shared some principles.
  • Everyone got some gifts when they registered (agenda, water bottle and some stickers)
  • Free food and unlimited Starbucks coffee is always great 🙂

The Bad

  • It was supposed to be an event which targets the enterprise world and I was expecting more engaged speakers. With a couple of exceptions the “slides” were even for me(a novice with AWS) poorly presented and highly repetitive. I think Amazon needs to choose more wisely who is on the stage since that person needs to capture the audience attention, my mind started to doodle.