Enterprise Framework

Software Solutions in the Enterprise

SSH GIT "client_loop: send disconnect: Connection aborted"

SSH GIT "client_loop: send disconnect: Connection aborted"


$ ssh git-codecommit.us-east-2.amazonaws.com
Warning: Permanently added the RSA host key for IP address '52.95.17.51' to the list of known hosts.
client_loop: send disconnect: Connection aborted


Solution:

This can be cause by a low connection.  Try increasing the timeout in your ~/.ssh/config file

Host git-codecommit.*.amazonaws.com
User ABKAUNZRXIY7XGYO6KYX
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
ServerAliveInterval 60
ServerAliveCountMax 100






AWS CodeCommit SSH GIT "Error Permission denied (publickey)" on Windows

AWS CodeCommit SSH GIT "Error Permission denied (publickey)" on Windows

Error:

git clone ssh://123456789012@git-codecommit.us-east-1.amazonaws.com/v1/repos/my-project
Cloning into 'my-project'...
123456789012@git-codecommit.us-east-1.amazonaws.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


Solution:  Verify .ssh Private and Public Keys


Upload the id_rsa.pub (File with .pub) to source control provider


Solution:  Correct ~/.ssh/config name

Ensure your ~/.ssh/config is named correctly.  (Not ~/.ssh/config.txt)  No .txt


Solution:  Correct ~.ssh/config content

Host git-codecommit.*.amazonaws.com
User APKBULZRXIY7XGYO7KYX
IdentityFile ~/.ssh/id_rsa


Solution:  Try Different SSH Git Clone commands

git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/directory-webapi

or

git clone ssh://123456789012@git-codecommit.us-east-1.amazonaws.com/v1/repos/my-project
or

from Bash Shell Prompt

Without Account Number

GIT_SSH_COMMAND="ssh" git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-project

or

With Account Number

GIT_SSH_COMMAND="ssh" git clone ssh://123456789012@git-codecommit.us-east-1.amazonaws.com/v1/repos/my-project


Error 'str' object has no attribute 'get' after running aws cli command

Error 'str' object has no attribute 'get' after running aws cli command


Problem:

After you run a aws cli command, you get the error "'str' object has no attribute 'get'" after running aws cli command

$ aws iam list-users

'str' object has no attribute 'get'


Solution:

The command is failing because it requires a aws profile specified in the cli command.  Can be found in your .aws/credentials file

$ aws iam list-users --profile my-profile



Mac AWS Amplify cli command is not found after npm install

Mac AWS Amplify cli command is not found after npm install


Problem:

Install AWS Amplify on Mac fails using npm.  amplify cli command is not found after npm install.

$ npm install -g @aws-amplify/cli

$ amplify
zsh: command not found: amplify

Solution:

Trying using cURL install instead for Mac or Linux
$ curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL

Reference:



Amazon.com Free AWS Training Online Courses

Amazon.com Free AWS Training Online Courses


Free Amazon.Com AWS Training Online Courses


Here are links to Amazon.com for Free AWS Training Online Courses


Here is the Amazon Results Page



You are running 'create-react-app' 4.0.3, which is behind the latest release (5.0.1) Error

You are running 'create-react-app' 4.0.3, which is behind the latest release (5.0.1) Error


Problem

npx has a cache with a reference

$ npx create-react-app my-app --template typescript

Need to install the following packages:
create-react-app
Ok to proceed? (y) y

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.1).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/


Solution

Clear the npx cache and try running again

$ npx clear-npx-cache
Need to install the following packages:
clear-npx-cache
Ok to proceed? (y) y

$ npx create-react-app my-app --template typescript



.NET Linq OrderBy String Property Name

.NET Linq OrderBy and/or ThenBy using String Property Name Dynamically


Original Reference from:

https://stackoverflow.com/questions/36298868/how-to-dynamically-order-by-certain-entity-properties-in-entity-framework-7-cor


Linq Extensions

This extension extends IQueryable and IOrderedQueryable for dynamic conditions and string name sorting

using System;
using System.Linq;
using System.Linq.Expressions;

public static class IQueryableExtensions
{
    public static IQueryable<TSource> WhereIf<TSource>(
        this IQueryable<TSource> source,
        bool condition,
        Func<IQueryable<TSource>, IQueryable<TSource>> branch)
    {
        return condition ? branch(source) : source;
    }

    public static IQueryable<TSource> IncludeIf<TSource>(
        this IQueryable<TSource> source,
        bool condition,
        Func<IQueryable<TSource>, IQueryable<TSource>> branch)
    {
        return condition ? branch(source) : source;
    }

       public static IOrderedQueryable<T> OrderBy<T>(this         IQueryable<T> source, string propertyName, bool ascending = true)
    {
        if (ascending) return source.OrderBy(ToLambda<T>(propertyName));

        return source.OrderByDescending(ToLambda<T>(propertyName));
    }

        public static IOrderedQueryable<T>         OrderByDescending<T>(this IQueryable<T> source, string         propertyName, bool ascending = true)
    {
        if (ascending) return source.OrderBy(ToLambda<T>(propertyName));

        return source.OrderByDescending(ToLambda<T>(propertyName));
    }

        public static IOrderedQueryable<T> ThenBy<T>(this         IOrderedQueryable<T> source, string propertyName, bool ascending =         true)
    {
        if (ascending) return source.ThenBy(ToLambda<T>(propertyName));

        return source.ThenByDescending(ToLambda<T>(propertyName));
    }

        public static IOrderedQueryable<T> ThenByDescending<T>(this         IOrderedQueryable<T> source, string propertyName, bool ascending =         true)
    {
        if (ascending) return source.ThenBy(ToLambda<T>(propertyName));

        return source.ThenByDescending(ToLambda<T>(propertyName));
    }

    private static Expression<Func<T, object>> ToLambda<T>(string propertyName)
    {
        var parameter = Expression.Parameter(typeof(T));
        var property = Expression.Property(parameter, propertyName);

        return Expression.Lambda<Func<T, object>>(property, parameter);
    }
}


ASP.NET Core appsettings.json with AzureAD Properties

ASP.NET Core appsettings.json with AzureAD Properties


Here are appsettings.json properties for configuration of AzureAD in ASP.NET Core


{
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "yourtenantdomain.onmicrosoft.com",
    "ClientId": "{ClientId}",
    "TenantId": "common",
    "CallbackPath": "/signin-oidc", // defaults to /signin-oidc
    "ClientSecret": "{YourSecret}",

}



Additional Examples


https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2