linux - 如何在 Azure 上使用 ssh 认证部署 Linux VM

标签 linux azure ssh command-line-interface x509certificate

当我使用无密码选项“-P”创建新的 vm Linux 并添加 .pem 文件的路径(如下所示)时,我遇到了 Windows azure 命令行界面问题

$ azure vm create myapimachine1 b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_2-LTS-amd64-server-20130325-en-us-30GB ahmed --location "West US" --ssh 22 -t /media/ahmed/1578-4B0E/WindowsAzure/AzureCert/mycert.pem -P  

Azure 要求我插入类型为 .pfx 而不是 pem 的证书:

info:    Executing command vm create
+ Looking up image                                                             
+ Looking up cloud service                                                     
warn:    --location option will be ignored
+ Getting cloud service properties                                             
+ Looking up deployment                                                        
+ Retrieving storage accounts                                                  
-error:   The certificate file is invalid. The certificate file must be a Base64-encoded .pfx file.
info:    Error information has been recorded to azure.err
error:   vm create command failed

当我使用 .pfx 证书运行相同的命令时,如下所示:

$ azure vm create myapimachine1 b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_2-LTS-amd64-server-20130325-en-us-30GB ahmed --location "West US" --ssh 22 -t /media/ahmed/1578-4B0E/WindowsAzure/AzureCert/mycert.pfx -P

Azure 命令行要求我添加 .pem 格式的 ssh 证书:

nfo:    Executing command vm create
+ Looking up image                                                             
+ Looking up cloud service                                                     
warn:    --location option will be ignored
+ Getting cloud service properties                                             
+ Looking up deployment                                                        
+ Retrieving storage accounts                                                  
error:   Specified SSH certificate is not in PEM format
info:    Error information has been recorded to azure.err
error:   vm create command failed

注意: 此进程在 Windows Azure 门户上正常工作,但我在 python 的 REST API 和 Azure CLI 中遇到此问题

谢谢

艾哈迈德·阿卜杜拉

最佳答案

我也遇到了这个问题(azure cli v0.8.11)

在查看源代码时,该工具正在查找以以下内容开头的文件

-----BEGIN CERTIFICATE----- 并以 -----END CERTIFICATE----- 结束。

(来自:lib/util/utils.js:34-35、252-254 和 lib/node_modules/azure_cli/vmclient.js:3448)

我怀疑查看/media/ahmed/1578-4B0E/WindowsAzure/AzureCert/mycert.pem 会发现

-----BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----

作为存在和结束标记,就像我的一样。

我找到了解决方案here ,它解释了问题所在并链接到 an article解释如何解决该问题。

(如果您赶时间,请使用命令的输出:

openssl req -x509 -key ~/.ssh/id_rsa -nodes -days 365 -newkey rsa:2048 -out myCert.pem

而不是裸键)。

关于linux - 如何在 Azure 上使用 ssh 认证部署 Linux VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19856385/

相关文章:

linux - 作为普通桌面用户登录后如何获取 root shell 以及如何修补它?

c# - 将 MVC-3 项目转换为 windows azure

linux - iperf UDP over IPv6

linux - 使用 nmap 更快地发现主机?

私有(private) VPN 中的 Azure Web 应用程序?

macos - 将文件从服务器复制到本地硬盘

git - 使用 Windows PowerShell 设置 .SSH key 时出错

Bash 脚本 "read"从 SSH shell 执行时不暂停用户输入

c - 是否可以在 CLion 中开发 linux 内核模块?

sql-server - 如何将我的 Azure Sql Server 管理员用户添加到 'Sysadmin' 服务器角色?