IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Create SSH Keys

The recommendation now is to use ED25519 whenever you can.

Commands

Using ED25519

ssh-keygen -t ed25519 -C "[email protected]"

Using RSA

ssh-keygen -t rsa -b 4096 -C "[email protected]"

-C is optional, if not used then the login and machine name is going to be used instead.

Use -b to specify key size.

Ways to create SSH keys on macOS

On Mac OSX and Linux

You just get to Terminal and start typing:

ssh-keygen -t ed25519 -C "[email protected]"

You can use either your email address as label or anything that can be used to remind you what you use the SSH key for.

On PC

You need to download an external client such as puttygen (from putty) or if you have GIT, you can use the bash shell interface as well and the command is the same.

ssh-keygen -t ed25519 -C "[email protected]"

Adding the Key

eval $(ssh-agent -s)

ssh-add ~/.ssh/id_keys

To see the Keys

ssh-add -l

To copy key to clipboard:

$ pbcopy < ~/.ssh/id_keys.pub

Further Reading

PuTTY: a free SSH and Telnet client
Git
SSH key-type, rsa, dsa, ecdsa, are there easy answers for which to choose when?
Use SSH keys to communicate with GitLab

February 7, 2023 Filed Under: How To Tagged With: Git, Linux, macOS, Windows

Basic Configuration in Git

After installing Git, you may want to do some basic configuration so you can have a proper versioning history and collaborate with others in a shared repository.

First thing, you want to do before anything is to set your name and email.

You can open Git Bash on Windows or Terminal for macOS.

Replacing the First, Last and email address with your own, type the following:

git config --global user.name "First Last"
git config --global user.email [email protected]

This will be useful when you collaborate with others to see who has made what changes in the repository.

The next one, you want to set how the end of the line is treated in Git. This is often overlooked by many and usually does not pose any issues if everyone uses the same system or you just use Git by yourself. However if you check in and out your code using different platforms, it can cause an issue.

A bit of explanation with the end of the line for each OS here. On Windows an end of line consists of two characters \r\n which is a carriage return followed by a line feed. macOS on the other hand, only uses \n (line feed) and no carriage return. As such, whenever someone checks code in or out, Git needs to know how to treat the line ends so everyone will have consistent experience. So we have to configure the core.autocrlf accordingly.

Windows

For Windows, typically when you accept default settings from Git installer, it will set it automatically to true. But just in case you checked the wrong option or you wanted to be sure, you can configure it manually.

Type the following in Git Bash:

git config --global core.autocrlf = true

macOS

For macOS, type the following in Terminal:

git config --global core.autocrlf = input

Git global config for core.autocrlf in macOS Terminal

Now you can verify all your configuration settings by typing this command:

git config --global --list

If you found any typo, you can always fix it by running the same command line with the correct information.

That’s it. This configuration typically is done just once.

Next, while optional, you might want to check this post if you want to use your favorite text editor as the default.

Further Reading

How to Use Your Favorite Text Editor in Git
Git git-config Documentation
How to Install Git

October 14, 2021 Filed Under: How To Tagged With: Git

How to Install Git

This may be a very basic topic, but it turned out to be very useful for people who are just starting to delve into version control software.

Just a quick overview from Pro Git book by Scott Chacon and Ben Straub that you can download from the link at the bottom of this post, this would give you a clearer explanation on why you should use it.

What is “version control”, and why should you care? Version control is asystem that records changes to a file or set of files over time so thatyou can recall specific versions later. For the examples in this book,you will use software source code as the files being version controlled,though in reality you can do this with nearly any type of file on acomputer.

If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead.

Now we can go back to the practical side of it on how to install it.

Windows

If you’re on Windows, the simplest thing to do is just head on to this link and download latest version of Git exe file.

Git download page for Windows

Run the exe and follow the instructions, then you’re done.

While it’s outside the scope of this post, you can also install Git from Visual Studio by checking the options when you install it. My personal preference though is to install Git separately and you can still access it from Visual Studio.

macOS (or Linux)

For Mac users, by default, you already have Git installed in your system, you just need to access it from the Terminal. The most common issue is the version of Git that’s installed is not the latest one. It’s certainly not a big issue if you’re just starting, but if you want to keep updating your Git to the latest version, you need to install your own.

You can check which version of Git you have by typing the following command in Terminal:

git --version

You can certainly download your own Git from as well, but I think the best way to do it is to install it using Homebrew package manager for macOS (or Linux).

Just install it from the Terminal by copying the command line on their page by clicking the notepad icon on the right. Then you can paste that command on your Terminal.

Homebrew Package Manager installation page

Once you have Homebrew installed, you can open your Terminal and type the following:

brew install git

That’s it.

You can run the command line again to verify if your default Git is replaced with the latest version that was installed from Homebrew:

git --version

Now you’re almost ready to use Git. Check on how to do a basic configuration in Git before we can use it.

Further Reading

Basic Configuration in Git
How to Use Your Favorite Text Editor in Git

Download

Git

References

Pro Git (FREE eBook)
Homebrew The Missing Package Manager for macOS (or Linux)

October 11, 2021 Filed Under: How To Tagged With: Git

How to Deploy Hugo Static Website to IIS Using Git

Continuing the posts on Hugo website tutorial, after all the setup is done, the question now is about static site hosting. The reality is hosting a static website is very easy so you have a lot of flexibility in choosing your hosting and platform. In fact, you can use Github, Bitbucket or Gitlab to host your static website.

This post will show you how you can host your static website on IIS server using a git-push.

Prerequisites

  1. Make sure IIS is setup. If you haven’t done so, make sure you check out the post to install IIS on Windows 10 which could be applied for Windows Server as well.
  2. You need to have Hugo installed on your system. Check out this post if you still need to install Hugo.
  3. Install Git. This process is also very straightforward, just head to Git website and follow its instructions to install it. You might also want to customize Git to work with your favorite text editor.If you decided to use Visual Studio Code, check out this post as the setup might be useful for editing and also publishing your Hugo website.
  4. You have already created a Hugo new site in a folder and you have already committed all the files with Git with a .gitignore file which has at the minimum the following entry:
    # Exclude folder
    public/
    
    # OS
    [Tt]humbs.db
    .DS_Store
    

For this exercise, I have my laptop as the source where I install all the tools and to write and generate the static website. For the IIS host, it will be a Windows 10 VM that can be mapped from the laptop. You can substitute the mapping with SSH for a different hosting but the principle is the same.

Now that we get all the prerequisites and objective out of the way, here are the steps to setup our environment:

Hugo/Git Public Folder Setup

    1. Important: Hugo publish the website to a sub-folder public, so we also need to Git initialize and commit all the files in sub-folder public separately from its parents folder. Remember, we exclude the public folder in .gitignore file (see the prerequisites). So we’re tracking the published website separately. It is from within this public folder that we do all the setup described below.
    2. On your target server, setup a folder that you can use as a temporary repository. In this example, a folder C:\inetpub\Git\hugo-repo was created for this purpose.
    3. We will publish the static content to default folder C:\inetpub\wwwroot.
    4. From within Git Bash and within your Hugo public folder, add the temporary repository as a remote repository by typing the following command:
      $ git remote add prod //MACHINENAME/c$/inetpub/Git/hugo-repo
      
    5. From within Git Bash, go to the remote repository to initialize it:
      $ cd //MACHINENAME/c$/inetpub/Git/hugo-repo
      
      $ git init --bare
      
    6. Go to the repo folder and open the hooks folder and create a new text file called post-receive (do not put any file extension) and edit it with the following code:
      #!/bin/bash
      
      git --work-tree=//MACHINENAME/c$/inetpub/wwwroot --git-dir=//MACHINENAME/c$/inetpub/Git/hugo-repo checkout -f
      

      Git post-receive hook file

If this sounds complicated, don’t worry about it as you only need to set this up once and forget about it.

Now every time you are ready to publish your Hugo website (i.e., by running the command “hugo”), go to your public folder, commit all the changes in Git, just do a Git push to prod:

$ git push prod master

The website will be automagically pushed to your IIS PROD and ready for public consumption.

We use this same exact method to publish an intranet site within our company. If there’s any step in this explanation is not clear, leave a comment below and I will try to improve the step-by-step guide in this post.

Further Reading

How to Install Hugo on Windows 10
How to Setup Visual Studio Code for Hugo Static Site Generator
How to Setup Naked Domain to Resolve in Cloudflare Pages

Downloads

Visual Studio Code
Git
Hugo

November 30, 2018 Filed Under: How To Tagged With: Git, Hugo, IIS, JAMStack

How to Use Your Favorite Text Editor in Git

After installing Git and initially configuring it, you can further configure it to use your favorite text editor as the default. What you need to do is set the value of core.editor to the program file of your editor and add a flag -w at the end. The -w basically is to tell Git to wait until all operations within the text editor is done before Git can continue to do its thing afterwards.

Windows

git config --global core.editor '"C:\Program Files\Sublime Text 4\sublime_text.exe" -w'

Pay attention to the placement of single quote (‘) and double quotes (“). You want to enclose the whole path of your editor within the quotes, then wrap the whole argument with the flag with the other.

You can use single quote or double quotes interchangeably as long as they’re consistent
(i.e., "'C:\Program Files\Sublime Text 4\sublime_text.exe' -w" works the same way as in the example above).

macOS / Linux

git config --global core.editor "subl -n -w"

Now, if you want to see if the text editor is set correctly, just type in this command:

git config --global --list

And you should see the core.editor value listed to look like this:
Git config --global --list command

Sublime Text is used as an example just because it’s available on Windows, OSX, and Linux. You can certainly substitute the path or program name with whatever text editor you have.

Using Visual Studio Code

Update 9/27/2021: If you use Visual Studio Code as your main editor, the setup is even more simple and this is actually is the more recommended setup now since this post was published (Visual Studio Code can be downloaded from the link at the bottom of this post).

You just need to type the following:

git config --global core.editor "code -w"

If you use macOS, before this configuration can work, you need to setup Visual Studio Code so it can be called from the command line. Then the Git setup to use it is the same on both Windows and macOS.

Further Reading

How to Open Visual Studio Code from command line macOS
How to Enable Font Ligatures in Visual Studio Code
How to Install Git
Basic Configuration in Git

Download

Visual Studio Code
Git

October 1, 2014 Filed Under: How To Tagged With: Code Editor, Git, Sublime Text, Visual Studio Code

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure