Category: SSH

  • Wait for host in BaSH

    Okay, this one is a little specific, but I recently had this issue and I wanted to share it because knowing this would have saved me one scripting language and a lot of time. I have previously implemented this in PowerShell, but it can easily be done in BaSH as well.

    The premise was to setup a new virtual machine and before I could work with the machine I had to wait until it was created and powered up. The installation was done in a pipeline and so there was no interaction. The following script waits until the machine is available and can be pinged and then terminates. This is not a finished solution but a small part of the pipeline that allowed me to continue with the regular installation via SSH after the machine was available.

  • Fix ssh Git connection against Azure DevOps

    I recently had the issue against my on premise Azure DevOps server, that the clone via ssh would fail with the message:

    PS C:\Users\goa> git clone ssh://devops.example.com:22/GoaSystems/Java/_git/my.java.project %SERPROFILE%\workspaces\java\my.java.project
    Unable to negotiate with 1.2.3.4 port 22: no matching host key type found. Their offer: ssh-rsa
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.

    The error can look different depending on if you already have a configuration file for SSH or not. But in any case, if a error is thrown, it is likely that the keys are the culprit. Fortunately this is easy to solve. Create the following file

    notepad %USERPROFILE%\.ssh\config

    and add the following content.

    Host devops.example.com
        User git
        PubkeyAcceptedAlgorithms +ssh-rsa
        HostkeyAlgorithms +ssh-rsa
        AddressFamily inet

    Modify it of course with your specifications (i.e. hostname).

    One could ask why “AddressFamily inet”. Well, shame on me, I don’t have IPv6 not properly set up due to a lack of understanding. So now I rely on IPv4 (what this line configures) in order to not have to wait for a timeout every time I’d like to clone something.