我有一个相当基本的场景。为此,我制作了一个专用的 ssh 密钥并将其添加到我的存储库机密中。
代码被推送到 master
GitHub 操作ssh通过执行将其上传到服务器echo "${{ secrets.SSH_KEY }}" > key。
之后,我可以使用此密钥连接到我的服务器,例如 ssh -i key devops@myserver.com lsb_release -a
问题是由于某种原因,GitHub 操作无法将其写入文件,而是将字符***而不是实际的秘密值写入文件。因此显然我无法连接到我的服务器。
如何使用此密钥与 ssh 连接?有没有不使用文件就可以连接的方法?使用 GitHub 操作完成此常见场景的人能否解释一下?
在 .NET Core 3.1 项目中,我添加了Microsoft.Extensions.Configuration.UserSecrets包,我单击了该项目来管理机密,该文件已在目录中创建AppData,并且UserSecretsId已自动添加到.csproj文件中。因为Host.CreateDefaultBuilder没有加载机密,所以我决定手动添加它们
if (hostContext.HostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets(Assembly.GetExecutingAssembly());
}
})
.Build();
Run Code Online (Sandbox Code Playgroud)
但后来我明白了
System.InvalidOperationException
HResult=0x80131509
Message=Could not find 'UserSecretsIdAttribute' on assembly 'XXX'.
Check that the project for 'XXX' has set the 'UserSecretsId' build property.
If the 'UserSecretsId' property is already set then add a reference to the Microsoft.Extensions.Configuration.UserSecrets package.
Source=Microsoft.Extensions.Configuration.UserSecrets
Run Code Online (Sandbox Code Playgroud)
我已经检查了expecion描述中的建议,并且这两个困境都得到了满足。
我编写了一个 lambda 函数来访问数据库,因此第一步是从 AWS Secrets Manager 获取机密。我有一个私有 VPC 以及与 lambda 函数关联的子网、NAT 网关和安全组。我也有secretsmanager.Secret.grantRead(lambda_exec_role)所以 lambda 应该可以访问 Secrets Manager。
出于某种原因,当我在 API Gateway 中测试它时,我在 CloudWatch 中得到了 "errno": "ETIMEDOUT" 和 "code": "NetworkingError"。从我在 API 中打印的日志来看,获取机密失败了。
我也试图为秘密管理器添加VPC的端点在这里,但仍然得到了同样的错误。
感谢这里的任何人可以帮助我解决这个问题或提供一些提示。
非常感谢!
amazon-web-services amazon-vpc aws-lambda secretsmanager aws-nat-gateway
我们有一个遗留的 .NET 解决方案,它结合了 MVC 和 WebForms 的东西,以及一些 Web API 项目作为网站根目录下的应用程序。显然,这些 Web API 应用程序将继承网站的 web.config 设置。
我们还有另一个项目——一个有界上下文——用于 SSO 身份验证,它位于同一个根文件夹内,因此也继承了网站的 web.config 设置。这个有界上下文应用程序是用 .NET Core 构建的。
- wwwroot // .NET Framework
- API 1 // .NET Framework
- API 2 // .NET Framework
- ...
- SSO / authentication // bounded context, built in .NET Core
Run Code Online (Sandbox Code Playgroud)
我们最近开始使用 Azure Key Vault 来存储我们的机密,为了在本地处理这些机密,我们使用了 secrets.xml 文件。所以根网站的 web.config 看起来像这样......
<configSections>
<section name="configBuilders" ... />
</configSections>
<configBuilders>
<builders>
<add name="Secrets" optional="false" userSecretsFile="~\secrets.xml" [elided attributes] />
</builders>
</configBuilders>
<appSettings …Run Code Online (Sandbox Code Playgroud) c# web-config subapplication secretsmanager asp-net-config-builders
我是 Asp.Net Core 和 EF 的新手。我正在从数据库端开发一个简单的 CRUD,使用该Secrets.json文件隐藏我的连接字符串凭据。
但我不知道如何使用 AddDbContext() 引用该文件。
到目前为止我的代码:
public class Startup
{
public Startup(IConfigurationRoot configuration)
{
Configuration = configuration;
}
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDbContext<POTS.myDBContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("myConxStr")));
services.AddControllers();
}
Run Code Online (Sandbox Code Playgroud)
当代码运行时,我收到此AddDbContext<>错误
System.ArgumentNullException HResult=0x80004003 Message=值不能为空。(参数'connectionString')
来源= Microsoft.EntityFrameworkCore.SqlServer StackTrace:等等
我认为这是因为代码正在文件中查找参数appsettings.json,而我不希望连接字符串在其中。
我缺少什么?
entity-framework connection-string asp.net-core secretsmanager
我想使用内置的秘密功能.NET Core,但它对我不起作用,我不明白为什么我正在做需要的事情。如果您能帮助我并让我知道缺少什么,我将不胜感激。
在开发人员命令中我运行这个:
dotnet user-secrets init
dotnet user-secrets set ConectionStrings:DGM "Data Source=.;Initial Catalog=DGM;Integrated Security=True;MultipleActiveResultSets=True;"
Run Code Online (Sandbox Code Playgroud)
在代码中:
string conn = config.GetConnectionString("DGM");
Run Code Online (Sandbox Code Playgroud)
配置是 IConfiguration。
conn 为空,为什么?