Jenkins Generate Ssh Key Windows

2018-7-4  If ssh credentials used with a passphrase, then Jenkins unable to fetch anything from the remote repo. Step to reproduce: Create a key with passphrase `ssh-keygen -b 2048 -t rsa -f testrsa` Add credentials 'SSH Username with private key' from the previous step; Add repo on. Add SSH key to a Jenkins Git step. Posted by Laszlo Pinter February 15, 2017 February 15, 2017 Leave a comment on Add SSH key to a Jenkins Git step. To access a Git repository Jenkins can use an SSH key. To add the SSH key to the Jenkins server use the following Chef script. REZURAsantoso on Docker for Windows cannot start. Q: How can I have Git remember the passphrase for my key on Windows? A: Run the following command included in Git for Windows to start up the ssh-agent process in Powershell or the Windows Command Prompt. Ssh-agent will cache your passphrase so you don't have to provide it every time you connect to your repo.

  1. 2 days ago  While GitLab does not support installation on Microsoft Windows, you can set up SSH keys to set up Windows as a client. Options for SSH keys. GitLab supports the use of RSA, DSA, ECDSA, and ED25519 keys. GitLab has deprecated DSA keys in GitLab 11.0.; As noted in Practical Cryptography With Go, the security issues related to DSA also apply to ECDSA.
  2. Generate SSH Key on Jenkins Server First, we create a directory named githubrepos on the Jenkins server and a hidden directory ssh under that: -bash-4.2$ mkdir githubrepos -bash-4.2$ cd githubrepos/ -bash-4.2$ mkdir.ssh -bash-4.2$ ls -al total 4 drwxrwxr-x. 3 jenkins jenkins 18 Feb 22 23:33. 30 jenkins jenkins 4096 Feb 22 23:33.
-->

This tutorial shows how to install Jenkins on an Ubuntu Linux VM with the tools and plug-ins configured to work with Azure. When you're finished, you have a Jenkins server running in Azure building a sample Java app from GitHub.

  • Install and configure a Jenkins server on Azure
  • Access the Jenkins console using an SSH tunnel
  • Create a Freestyle project
  • Compile the code and package the sample app

Prerequisites

  • An Azure subscription
  • Access to SSH on your computer's command line (such as the Bash shell or PuTTY)

If you don't have an Azure subscription, create a free account before you begin.

Create the Jenkins VM from the solution template

Jenkins supports a model where the Jenkins server delegates work to one or more agents to allow a single Jenkins installation to host a large number of projects or to provide different environments needed for builds or tests. The steps in this section guide you through installing and configuring a Jenkins server on Azure.

  1. In your browser, open the Azure Marketplace image for Jenkins.

  2. Select GET IT NOW.

  3. After reviewing the pricing details and terms information, select Continue.

  4. Select Create to configure the Jenkins server in the Azure portal.

  5. In the Basics tab, specify the following values:

    • Name - Enter Jenkins.

    • User name - Enter the user name to use when signing in to the virtual machine on which Jenkins is running. The user name must meet specific requirements.

    • Authentication type - Select SSH public key.

    • SSH public key - Copy and paste an RSA public key in single-line format (starting with ssh-rsa) or multi-line PEM format. You can generate SSH keys using ssh-keygen on Linux and macOS, or PuTTYGen on Windows. For more information about SSH keys and Azure, see the article, How to Use SSH keys with Windows on Azure.

    • Subscription - Select the Azure subscription into which you want to install Jenkins.

    • Resource group - Select Create new, and enter a name for the resource group that serves as a logical container for the collection of resources that make up your Jenkins installation.

    • Location - Select East US.

  6. Select OK to proceed to the Additional Settings tab.

  7. In the Additional Settings tab, specify the following values:

    • Size - Select the appropriate sizing option for your Jenkins virtual machine.

    • Age of wonders 3 serial key generator. VM disk type - Specify either HDD (hard-disk drive) or SSD (solid-state drive) to indicate which storage disk type is allowed for the Jenkins virtual machine.

    • Virtual network - (Optional) Select Virtual network to modify the default settings.

    • Subnets - Select Subnets, verify the information, and select OK.

    • Public IP address - The IP address name defaults to the Jenkins name you specified in the previous page with a suffix of -IP. You can select the option to change that default.

    • Domain name label - Specify the value for the fully qualified URL to the Jenkins virtual machine.

    • Jenkins release type - Select the desired release type from the options: LTS, Weekly build, or Azure Verified. The LTS and Weekly build options are explained in the article, Jenkins LTS Release Line. The Azure Verified option refers to a Jenkins LTS version that has been verified to run on Azure.

    • JDK Type - JDK to be installed. Default is Zulu tested, certified builds of OpenJDK.

  8. Select OK to proceed to the Integration Settings tab.

  9. In the Integration Settings tab, specify the following values:

    • Service Principal - The service principal is added into Jenkins as a credential for authentication with Azure. Auto means that the principal will be created by MSI (Managed Service Identity). Manual means that the principal should be created by you.
      • Application ID and Secret - If you select the Manual option for the Service Principal option, you'll need to specify the Application ID and Secret for your service principal. When creating a service principal, note that the default role is Contributor, which is sufficient for working with Azure resources.
    • Enable Cloud Agents - Specify the default cloud template for agents where ACI refers to Azure Container Instance, and VM refers to virtual machines. You can also specify No if you don't wish to enable a cloud agent.
  10. Select OK to proceed to the Summary tab.

  11. When the Summary tab displays, the information entered is validated. Once you see the Validation passed message (at the top of the tab), select OK.

  12. When the Create tab displays, select Create to create the Jenkins virtual machine. When your server is ready, a notification displays in the Azure portal.

Connect to Jenkins

Navigate to your virtual machine (for example, http://jenkins2517454.eastus.cloudapp.azure.com/) in your web browser. The Jenkins console is inaccessible through unsecured HTTP so instructions are provided on the page to access the Jenkins console securely from your computer using an SSH tunnel.

Set up the tunnel using the ssh command on the page from the command line, replacing username with the name of the virtual machine admin user chosen earlier when setting up the virtual machine from the solution template.

After you have started the tunnel, navigate to http://localhost:8080/ on your local machine.

Get the initial password by running the following command in the command line while connected through SSH to the Jenkins VM.

Unlock the Jenkins dashboard for the first time using this initial password.

Select Install suggested plugins on the next page and then create a Jenkins admin user used to access the Jenkins dashboard.

The Jenkins server is now ready to build code.

Create your first job

Create Ssh Key

Select Create new jobs from the Jenkins console, then name it mySampleApp and select Freestyle project, then select OK.

Select the Source Code Management tab, enable Git, and enter the following URL in Repository URL field: https://github.com/spring-guides/gs-spring-boot.git

Select the Build tab, then select Add build step, Invoke Gradle script. Select Use Gradle Wrapper, then enter complete in Wrapper location and build for Tasks.

Select Advanced and then enter complete in the Root Build script field. Select Save.

Build the code

Select Build Now to compile the code and package the sample app. When your build completes, select the Workspace link for the project.

Navigate to complete/build/libs and ensure the gs-spring-boot-0.1.0.jar is there to verify that your build was successful. Your Jenkins server is now ready to build your own projects in Azure.

Troubleshooting the Jenkins solution template

If you encounter any bugs with the Jenkins solution template, file an issue in the Jenkins GitHub repo.

Next Steps

-->

This article describes ways to generate and use secure shell (SSH) keys on a Windows computer to create and connect to a Linux virtual machine (VM) in Azure. To use SSH keys from a Linux or macOS client, see the quick or detailed guidance.

Overview of SSH and keys

SSH is an encrypted connection protocol that allows secure sign-ins over unsecured connections. SSH is the default connection protocol for Linux VMs hosted in Azure. Although SSH itself provides an encrypted connection, using passwords with SSH connections still leaves the VM vulnerable to brute-force attacks or guessing of passwords. A more secure and preferred method of connecting to a VM using SSH is by using a public-private key pair, also known as SSH keys.

  • The public key is placed on your Linux VM, or any other service that you wish to use with public-key cryptography.

  • The private key remains on your local system. Protect this private key. Do not share it.

When you use an SSH client to connect to your Linux VM (which has the public key), the remote VM tests the client to make sure it possesses the private key. If the client has the private key, it's granted access to the VM.

Depending on your organization's security policies, you can reuse a single public-private key pair to access multiple Azure VMs and services. You do not need a separate pair of keys for each VM or service you wish to access.

Generate Ssh Key Windows

Your public key can be shared with anyone, but only you (or your local security infrastructure) should possess your private key.

Supported SSH key formats

Azure currently supports SSH protocol 2 (SSH-2) RSA public-private key pairs with a minimum length of 2048 bits. Other key formats such as ED25519 and ECDSA are not supported.

Windows packages and SSH clients

You connect to and manage Linux VMs in Azure using an SSH client. Computers running Linux or macOS usually have a suite of SSH commands to generate and manage SSH keys and to make SSH connections.

Windows computers do not always have comparable SSH commands installed. Recent versions of Windows 10 provide OpenSSH client commands to create and manage SSH keys and make SSH connections from a command prompt. Recent Windows 10 versions also include the Windows Subsystem for Linux to run and access utilities such as an SSH client natively within a Bash shell.

Other common Windows SSH clients you can install locally are included in the following packages:

You can also use the SSH utilities available in Bash in the Azure Cloud Shell.

  • Access Cloud Shell in your web browser at https://shell.azure.com or in the Azure portal.
  • Access Cloud Shell as a terminal from within Visual Studio Code by installing the Azure Account extension.

Create an SSH key pair

The following sections describe two options to create an SSH key pair on Windows. You can use a shell command (ssh-keygen) or a GUI tool (PuTTYgen). Also note, when using Powershell to create a key, upload the public key as ssh.com(SECSH) format. When using CLI, convert the key into OpenSSH format prior to uploading.

Create SSH keys with ssh-keygen

If you run a command shell on Windows that supports SSH client tools (or you use Azure Cloud Shell), create an SSH key pair using the ssh-keygen command. Type the following command, and answer the prompts. If an SSH key pair exists in the chosen location, those files are overwritten.

For more background and information, see the quick or detailed steps to create SSH keys using ssh-keygen.

Create SSH keys with PuTTYgen

If you prefer to use a GUI-based tool to create SSH keys, you can use the PuTTYgen key generator, included with the PuTTY download package.

To create an SSH RSA key pair with PuTTYgen:

  1. Start PuTTYgen.

  2. Click Generate. By default PuTTYgen generates a 2048-bit SSH-2 RSA key.

  3. Move the mouse around in the blank area to provide randomness for the key.

  4. After the public key is generated, optionally enter and confirm a passphrase. You will be prompted for the passphrase when you authenticate to the VM with your private SSH key. Without a passphrase, if someone obtains your private key, they can sign in to any VM or service that uses that key. We recommend you create a passphrase. However, if you forget the passphrase, there is no way to recover it.

  5. The public key is displayed at the top of the window. You can copy this entire public key and then paste it into the Azure portal or an Azure Resource Manager template when you create a Linux VM. You can also select Save public key to save a copy to your computer:

  6. Optionally, to save the private key in PuTTy private key format (.ppk file), select Save private key. You will need the .ppk file later to use PuTTY to make an SSH connection to the VM.

    If you want to save the private key in the OpenSSH format, the private key format used by many SSH clients, select Conversions > Export OpenSSH key.

Provide an SSH public key when deploying a VM

To create a Linux VM that uses SSH keys for authentication, provide your SSH public key when creating the VM using the Azure portal or other methods.

The following example shows how you would copy and paste this public key into the Azure portal when you create a Linux VM. The public key is typically then stored in the ~/.ssh/authorized_key directory on your new VM.

Connect to your VM

One way to make an SSH connection to your Linux VM from Windows is to use an SSH client. This is the preferred method if you have an SSH client installed on your Windows system, or if you use the SSH tools in Bash in Azure Cloud Shell. If you prefer a GUI-based tool, you can connect with PuTTY.

Use an SSH client

With the public key deployed on your Azure VM, and the private key on your local system, SSH to your VM using the IP address or DNS name of your VM. Replace azureuser and myvm.westus.cloudapp.azure.com in the following command with the administrator user name and the fully qualified domain name (or IP address):

If you configured a passphrase when you created your key pair, enter the passphrase when prompted during the sign-in process.

If the VM is using the just-in-time access policy, you need to request access before you can connect to the VM. For more information about the just-in-time policy, see Manage virtual machine access using the just in time policy.

Connect with PuTTY

If you installed the PuTTY download package and previously generated a PuTTY private key (.ppk) file, you can connect to a Linux VM with PuTTY.

  1. Start PuTTy.

  2. Fill in the host name or IP address of your VM from the Azure portal:

  3. Select the Connection > SSH > Auth category. Browse to and select your PuTTY private key (.ppk file):

  4. Click Open to connect to your VM.

Next steps

Generate Ssh Keys

  • For detailed steps, options, and advanced examples of working with SSH keys, see Detailed steps to create SSH key pairs.

  • You can also use PowerShell in Azure Cloud Shell to generate SSH keys and make SSH connections to Linux VMs. See the PowerShell quickstart.

  • If you have difficulty using SSH to connect to your Linux VMs, see Troubleshoot SSH connections to an Azure Linux VM.