r - 通过 R 使用 Linux Azure DSVM 进行 SSH 公钥身份验证

标签 r azure ssh azure-active-directory azure-dsvm

我正在尝试使用 R AzureDSVM 包通过 R 创建 Linux DSVM。我正在阅读指南 https://raw.githubusercontent.com/Azure/AzureDSVM/master/vignettes/10Deploy.Rmd(Azure DSVM 指南)

首先,指南要求您创建一个 Azure Active Directory 应用程序,该应用程序将提供“租户 ID”、“客户端 ID”和“用户 key ”,http://htmlpreview.github.io/?https://github.com/Microsoft/AzureSMR/blob/master/inst/doc/Authentication.html(Azure SMR 身份验证指南)中描述的指南

据我了解,这会创建一个在 Azure Active Directory 中注册的应用程序,为该应用程序创建一个“身份验证 key ”(即用户 key ),并将该应用程序与资源组关联起来。我已经成功地做到了这一点。

然后,Azure DSVM 指南会按照与以下类似的方式创建具有公钥身份验证的 VM:

library(AzureSMR) 
library(AzureDSVM)   

TID <- "123abc"          # Tenant ID
CID <- "456def"          # Client ID
KEY <- "789ghi"          # User key

context <- createAzureContext(tenantID=TID, clientID=CID, authKey=KEY)

resourceGroup<-"myResouceGroup"
location<-"myAzureLocation"
vmUsername<-"myVmUsername"
size<-"Standard_D1_v2"
mrsVmPassword<-"myVmPassword"
hostname<-"myVmHostname"

ldsvm <- deployDSVM(context, 
                    resource.group = resourceGroup,
                    location       = location,
                    hostname       = hostname,
                    username       = vmUsername,
                    size           = size,
                    os = "Ubuntu",
                    pubkey         = PUBKEY)

该指南模糊地描述了从用户私钥创建公钥 (PUBKEY),该私钥被发送到虚拟机以允许其提供 SSH 身份验证:

To get started we need to load our Azure credentials as well as the user’s ssh public key. Public keys on Linux are typically created on the users desktop/laptop machine and will be found within ~/.ssh/id_rsa.pub. It will be convenient to create a credentials file to contain this information. The contents of the credentials file will be something like the foloowing and we assume the user creates such a file in the current working directory, naming the file _credentials.R. Replace with the user’s username.

TID <- "72f9....db47"          # Tenant ID
CID <- "9c52....074a"          # Client ID
KEY <- "9Efb....4nwV....ASa8=" # User key

PUBKEY   <- readLines("~/.ssh/id_rsa.pub") # For Linux DSVM

我的问题:

此公钥 PUBKEY 是通过在 Azure SMR 身份验证指南中设置 Azure Active Directory 应用程序(上述脚本中的 KEY 变量)创建的身份验证/用户 key 生成的吗?如果是这样,怎么办?我尝试使用 R 钠库 pubkey(charToRaw(KEY)) 来执行此操作,但我收到“无效 key ,必须恰好为 32 字节”。

如果 PUBKEY 不是由 KEY 生成的,那么它是由什么生成的?包如何知道如何使用私钥对此公钥进行身份验证?

最佳答案

AAD key 用于对 AAD 进行身份验证。公钥/私钥对是独立的,用于对虚拟机进行身份验证。如果您没有公钥(在文件 ~/.ssh/id_rsa.pub 中),您可以使用 ssh-keygen 创建一个在 Linux 上。

SSH 连接默认使用私钥(在 ~/.ssh/id_rsa 中)。

关于r - 通过 R 使用 Linux Azure DSVM 进行 SSH 公钥身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54330030/

相关文章:

c# - 从 Azure Blob 存储和 ASP.NET Core 3 流式传输视频

Python - 如何通过 ssh 使用变量 grep 到远程机器

r - R 中每列中缺失值的数量

azure - 使用 Cosmos DB 绑定(bind)从 Azure 函数执行 Cosmos DB 服务器端触发器

azure - Hive 管理的表不会掉落在 azure 数据湖存储上

mysql - 通过 navicat ssh 隧道连接 mysql 时 ssh_options_set 中的参数无效

PHP:通过现有的 SSH 连接进行 SSH

r - R plotly中的离散颜色条

R Shiny 仪表板仅加载一次选项卡

r - 增加接近于零的值的色标分辨率