One place for hosting & domains

      Windows

      Developing on Windows With the WSL


      How to Join

      This Tech Talk is free and open to everyone. Register below to get a link to join the live stream or receive the video recording after it airs.

      DateTimeRSVP
      June 9, 202111:00 a.m.–12:00 p.m. ET / 3:00–4:00 p.m. GMT

      About the Talk

      Wish you had a Linux command line experience on Windows? The Windows Subsystem for Linux can give you this! In this talk, we’ll install the WSL, go over how it works and how to use it, install the new Windows Command Line, and configure our IDEs and Docker to integrate with the WSL. Come learn about the WSL, how to install it and how to use it to develop your next idea.

      What You’ll Learn

      • How to install the Windows Subsystem for Linux and new Windows Command Line
      • How to integrate Docker with WSL
      • How to integrate WSL with your IDEs

      This Talk Is Designed For

      Software engineers who want to program on Windows.

      To join the live Tech Talk, register here.



      Source link

      How To Create SSH Keys with OpenSSH on macOS, Linux, or Windows Subsystem for Linux


      Introduction

      When setting up a remote Linux server, you’ll need to decide upon a method for securely connecting to it. While passwords are one way of verifying a user’s identity, passwords have multiple vulnerabilities and can be cracked by a brute force attack. Secure Shell keys — better known as SSH keys — are often used instead of passwords, as they offer a more secure method of connecting to remote Linux servers. As part of the Secure Shell cryptographic network protocol, SSH keys also enable users to securely perform network services over an unsecured network, such as delivering text-based commands to a remote server or configuring its services.

      This tutorial will guide you through the steps of creating SSH keys with OpenSSH, a suite of open source SSH tools, on macOS and Linux, as well as on Windows through the use of the Windows Subsystem for Linux. It is written for an audience that is just getting started with the command line and will provide guidance on accessing the terminal on a personal computer. After completing this tutorial, you will have SSH keys that can be used to securely set up a server in the tutorial How To Set Up an Ubuntu 20.04 Server on a DigitalOcean Droplet that is part of the Introduction to the Cloud Curriculum (coming soon).

      If you are already familiar with the command line and looking for instructions on using SSH to connect to a remote server, please see our collection of tutorials on Setting Up SSH Keys for a range of Linux operating systems.

      Prerequisites

      To complete this tutorial, you will need:

      • A local machine running one of the following operating systems: macOS, Linux, or Windows with Windows Subsystem for Linux installed. If you are using Windows, you can find instructions for downloading or updating the Windows Subsystem for Linux on Microsoft’s documentation page. Note that while OpenSSH should work for a range of Linux distributions, this tutorial has been tested using Ubuntu 20.04.

      Note: If you are looking for instructions on how to create SSH keys on a Windows machine that does not have the Windows Subsystem for Linux, please visit our product documentation How to Create SSH Keys with PuTTY on Windows.

      • Some familiarity with working with a terminal and the command line. If you need an introduction to working with terminals and the command line, you can visit our guide A Linux Command Line Primer (coming soon).

      Step 1 — Understanding SSH Keys

      SSH keys are two long strings of characters that can be used to authenticate the identity of a user requesting access to a remote server. These keys are generated by the user on their local computer using a SSH utility. One key is private and stored on the user’s local machine. The other key is public and shared with the remote server or any other entity the user wishes to securely communicate with.

      When a user requests to connect to a server with SSH, the server sends a message encrypted with the public key that can only be decrypted by the associated private key. The user’s local machine then uses its private key to attempt to decrypt the message. If the message is successfully decrypted, the server grants the user access without the need of a password. Once authenticated, users can launch a remote shell session in their local terminal to deliver text-based commands to the remote server.

      In the next step, you will open a terminal on your computer so that you can access the SSH utility used to generate a pair of SSH keys.

      Step 2 — Opening a Terminal on Your Computer

      A terminal allows you to interact with your computer through text-based commands rather than a graphical user interface. The way you access the terminal on your computer will depend on what type of operating system you are using.

      On machines running macOS, the Terminal application is typically located in the Utilities folder inside the Applications folder. You can also find it by searching for “terminal” in the Search Spotlight.

      If you are working on a Linux computer, your distribution’s default terminal application is also typically located in the Utilities folder inside the Applications folder. You can also find it by searching for “terminal” with the Desktop search functionality.

      If you are working on a Windows machine running Windows Subsystem for Linux, a Linux terminal should open immediately after installation. You can also find it by searching for “Ubuntu” with the Desktop search functionality.

      Once you have located your system’s terminal application, open up a new terminal window. Your terminal should display your user name, a dollar sign ($), and a cursor. This is where you will begin to type commands to tell the terminal what to do.

      In the next step, you will enter a text-based command to generate a pair of SSH keys.

      Step 3 — Generating Keys With OpenSSH

      Your macOS or Linux operating system should have the standard OpenSSH suite of tools already installed. This suite of tools includes the utility ssh-keygen, which you will use to generate a pair of SSH keys.

      Type the following command into your terminal:

      You will then be prompted to select a location for the keys. By default, the keys are stored in the ~/.ssh directory with the filenames id_rsa for the private key and id_rsa.pub for the public key. Using the default locations allows your SSH client to automatically find your SSH keys when authenticating, so we recommend accepting these default options. To do so, press ENTER:

      Output

      Generating public/private rsa key pair. Enter file in which to save the key (/home/sammy/.ssh/id_rsa):

      Warning: If you have previously generated a key pair, you will be prompted to confirm that you actually want to overwrite the existing key:

      Output

      /home/sammy/.ssh/id_rsa already exists. Overwrite (y/n)?

      If you choose to overwrite the key on disk, you will not be able to authenticate using the previous key anymore. Selecting “yes” is an irreversible destructive process.

      If you’re certain that you want to overwrite the existing key on disk, you can do so by pressing Y and then ENTER.

      If you choose the default location, your public key will be located in /home/sammy/.ssh/id_rsa.pub and your private key will be located in /home/sammy/.ssh/id_rsa. Note that in your filepath, sammy will be replaced with your username.

      After selecting a location for the key, you’ll be prompted to enter an optional passphrase which encrypts the private key file on disk.

      If you enter a passphrase, you will have to provide it every time you use this key (unless you are running SSH agent software that stores the decrypted key). We recommend using a passphrase, but you can just press ENTER to bypass this prompt:

      Output

      Created directory '/home/sammy/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again:

      Following that final prompt, your system will generate the SSH key pair:

      Output

      Your identification has been saved in /home/sammy/.ssh/id_rsa. Your public key has been saved in /home/sammy/.ssh/id_rsa.pub. The key fingerprint is: a9:49:EX:AM:PL:E3:3e:a9:de:4e:77:11:58:b6:90:26 sammy@203.0.113.0 The key's randomart image is: +--[ RSA 2048]----+ | ..o | | E o= . | | o. o | | .. | | ..S | | o o. | | =o.+. | |. =++.. | |o=++. | +-----------------+

      You now have a public and private key that you can use to authenticate.

      Conclusion

      Congratulations, you have now generated a pair of SSH keys. These keys can be used to securely connect with a remote server and are necessary for the tutorial How To Set Up an Ubuntu 20.04 Server on a DigitalOcean Droplet that follows this tutorial in the Introduction to the Cloud Curriculum (coming soon).

      For a deeper dive on working using SSH, please visit our guide SSH Essentials: Working With SSH Servers, Clients, and Keys.



      Source link

      Trying the New WSL 2. It’s Fast! (Windows Subsystem for Linux)


      In this post, I cover some first impressions from my experience installing and running WSL2 (Windows Subsystem for Linux) in my dev workflow.

      I haven’t done any exhaustive, scientific, or precise tests by any means. What I have found though is that WSL is about 5 times faster for everyday web development tasks like npm or yarn.

      Also, hot reloading and working with create-react-app or the vue-cli is faster!

      Read on for installation, getting started, gotchas, and specific timing on npx create-react-app

      What does WSL 2 bring?

      This is the process I went through and the surprises I encountered while installing.

      Installing WSL2 on Windows 10

      Microsoft now has stable documentation on how to install WSL and update to WSL2.

      To get up and running, follow the guide above through to the point where you set up a new linux distribution.

      Checking if the Install Worked

      The following command will show us what distros we have installed and what version they are on:

      • wsl --list --verbose
      • # or shorthand
      • wsl -l -v

      Installation Failure

      If you already had Ubuntu installed on WSL 1, you may have to completely uninstall and reinstall it.

      If your computer is having trouble running the update command (like my computer), then you may want to completely uninstall and reinstall your distro.

      I went into the Windows settings under Apps > Apps and Features and uninstalled Ubuntu:

      Then I made sure that the default version I wanted for all new installs was version 2:

      • wsl --set-default-version 2

      Now we can go into the Windows Store to install it:

      Once we’re installed, then we can check to be sure that version 2 was installed. Open up Powershell and run:

      Running WSL

      You can open up Windows Terminal and use the Ubuntu dropdown:

      Alternatively you can open up either cmd or Powershell and run:

      • # open up windows subsystem for linux
      • wsl

      Gotchas with WSL 2

      Speed when transferring between file systems is a little slow right now. That’s not a worry for me since I never transferred. I worked solely inside of my Windows files which were mounted into the Linux system.

      Here’s a guide on User Experience changes from WSL 1 to WSL 2. The two big gotchas are:

      1. Move your files into the Linux file system instead of your Windows system
      2. You will need to access localhost apps like [localhost:3000](http://localhost:3000) via an IP address like 192.168.28.2:3000

      Move all files into Linux

      To take advantage of all the new speed improvements in WSL 2, our files will need to be moved into the Linux filesystem.

      The best way to figure out where to move your files is to find the home directory in Linux, then open it in Windows explorer. Run the following:

      • # find the home folder
      • cd ~
      • # open up windows explorer for this folder
      • explorer.exe .

      Notice the path as a Network path:

      We can now move our files from our Windows folders into this new networked folder. We’ll be able to access it from our WSL and interact with it as if it were still in the same Windows files.

      For instance, we can install Node using a tool like n and then run npm start to run a local server for let’s say a React app.

      Network Isn’t localhost Yet

      When we create an app using create-react-app or the vue-cli, we will usually run a command like yarn start or yarn serve to run a local server.

      Normally we would be able to check on our application right in our browser using [localhost:3000](http://localhost:3000) for React or [localhost:8080](http://localhost:8080) for Vue.

      In the early stages of WSL 2, we can’t use localhost. We need to use an IP since Linux is inside a VM.

      To access your application currently, we will use an IP.

      Notice the 192.168.28.2:3000. We’ll use that to access our application:

      A Quick Comparison and Speed Test

      This entire exercise was to get a setup that was faster than the previous one. Let’s see if this setup is any faster!

      I don’t have anything too scientific. I’ll go back and run more tests, but I was frustrated how long a new React app took WSL 1 to make.

      For now, our test will be to run npx create-react-app my-new-app.

      We’ll be comparing the following machines. I know this isn’t scientific at all. I wish I had more computers with similar setups. I wish I had done these speed tests before I upgraded to WSL 2. Oh well. We have what we have!

      • My desktop machine (super powerful, more than the laptops for sure)
      • Surface Book 2 15" i7
      • MacBook Pro 15" 2015
      • npx create-react-app my-new-app

      Here are the numbers I got from running the test a few times on each platform.

      • Surface Book 2 WSL 1: 257 seconds
      • Surface Book 2 WSL 2: 52 seconds
      • 2015 MacBook Pro: 45 seconds
      • 2018 MacBook Pro: 38 seconds

      While still not as fast as the latest MacBook Pro, WSL 2 has made significant improvements over WSL 1.

      What’s Next?

      We’ll keep getting updates and I’ll keep testing to see if performance is improving. I would love to get to a point where WSL 2 on Windows could be as fast as a 2018 MacBook Pro.

      I love both Windows and Mac platforms and with WSL 2, my tools on both platforms has gotten even closer:

      Happy coding!



      Source link