Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从映像构建后ssh到azure vm_Azure_Ubuntu_Ssh_Virtual Machine_Azure Cli2 - Fatal编程技术网

从映像构建后ssh到azure vm

从映像构建后ssh到azure vm,azure,ubuntu,ssh,virtual-machine,azure-cli2,Azure,Ubuntu,Ssh,Virtual Machine,Azure Cli2,我已经从一个现有的ubuntu虚拟机创建了一个映像。之后,我使用azure文档基于该映像创建了一些VM。我在CLI中用于创建VM的命令是 az vm create --resource-group <groupname> --name <vmname> --image <imagename> --admin-username <adminname> --ssh-key-value ~/.ssh/id_rsa.pub az vm create--资

我已经从一个现有的ubuntu虚拟机创建了一个映像。之后,我使用azure文档基于该映像创建了一些VM。我在CLI中用于创建VM的命令是

az vm create --resource-group <groupname> --name <vmname>
--image <imagename> --admin-username <adminname>
--ssh-key-value ~/.ssh/id_rsa.pub
az vm create--资源组--名称
--image--管理员用户名
--ssh密钥值~/.ssh/id\u rsa.pub
创建的虚拟机很好,但我无法通过ssh连接到它们。当我

ssh -v <adminname>@IP
ssh-v@IP
我明白了

mongo1@Mongo1:~$ssh-vpaunix@10.0.0.5
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2,OpenSSL 1.0.2g 2016年3月1日
debug1:读取配置数据/etc/ssh/ssh\u config
debug1:/etc/ssh/ssh\u配置第19行:应用*
debug1:连接到10.0.0.5[10.0.0.5]端口22。
debug1:已建立连接。
debug1:identity file/home/mongo1/.ssh/id\u rsa类型1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id\u rsa-cert类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id_dsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id_dsa-cert type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id_ecdsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id_ecdsa-cert type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id_ed25519 type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/mongo1/.ssh/id_ed25519-cert type-1
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1:远程协议版本2.0,远程软件版本OpenSSH_7.4p1 Ubuntu-10
debug1:match:OpenSSH_7.4p1 Ubuntu-10 pat OpenSSH*compat 0x04000000
debug1:将10.0.0.5:22验证为“paunix”
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:算法:curve25519-sha256@libssh.org
debug1:kex:主机密钥算法:ecdsa-sha2-nistp256
debug1:kex:server->client cipher:chachacha20-poly1305@openssh.comMAC:压缩:无
debug1:kex:client->server cipher:chachacha20-poly1305@openssh.comMAC:压缩:无
debug1:需要SSH2\u MSG\u KEX\u ECDH\u回复
debug1:服务器主机密钥:ecdsa-sha2-nistp256 SHA256:SJnFJndqGBMkZB/Nq81uolEjv7tbMZ404S6424PIoSw
debug1:主机“10.0.0.5”已知,并且与ECDSA主机密钥匹配。
debug1:在/home/mongo1/.ssh/known_hosts中找到密钥:6
debug1:在134217728块之后重新键入
debug1:SSH2\u MSG\u已发送新密钥
debug1:应为SSH2\u MSG\u NEWKEYS
debug1:在134217728块之后重新键入
debug1:SSH2\u MSG\u接收到新密钥
debug1:SSH2\u MSG\u EXT\u接收到信息
debug1:kex_输入_外部_信息:服务器信号algs=
debug1:SSH2\u消息\u服务\u接收
debug1:可以继续的身份验证:公钥
debug1:下一个身份验证方法:公钥
debug1:提供RSA公钥:/home/mongo1/.ssh/id\u RSA
debug1:可以继续的身份验证:公钥
debug1:正在尝试私钥:/home/mongo1/.ssh/id\u dsa
debug1:正在尝试私钥:/home/mongo1/.ssh/id\u ecdsa
debug1:正在尝试私钥:/home/mongo1/.ssh/id_ed25519
debug1:不再尝试验证方法。
权限被拒绝(公钥)。

我对azure unix这个东西还不熟悉,所以我只能假设它与创建VM的命令中的“ssh密钥值”有关。。。我必须做什么才能ssh到vms?哦,虚拟机的操作系统是Ubuntu-16.04…

根据您的错误日志,您在
~/.ssh
中没有私钥

请使用
ssh-keygen
创建新的密钥对,并使用Azure CLI再次创建新的VM

如果你知道你的私人位置。您可以使用
ssh-iuser@ip
以ssh方式连接虚拟机


另一个解决方案是在创建VM时,使用
--生成ssh密钥
替换
--ssh密钥值~/.ssh/id\u rsa.pub

如果不想删除VM,可以使用Azure自定义脚本扩展向VM添加新的公钥。请参考此感谢盛宝,您的评论有帮助!Stack Overflow是一个关于编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参见帮助中心中的。也许或者会是一个更好的问的地方。嗯,不完全是。。。我做了一些变通。我很确定问题是我对unix、azure等缺乏了解。。。
mongo1@Mongo1:~$ ssh -v paunix@10.0.0.5
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.0.0.5 [10.0.0.5] port 22.
debug1: Connection established.
debug1: identity file /home/mongo1/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/mongo1/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Ubuntu-10
debug1: match: OpenSSH_7.4p1 Ubuntu-10 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.0.0.5:22 as 'paunix'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:SJnFJndqGBMkZB/Nq81uolEjv7tbMZ404S6424PIoSw
debug1: Host '10.0.0.5' is known and matches the ECDSA host key.
debug1: Found key in /home/mongo1/.ssh/known_hosts:6
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/mongo1/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/mongo1/.ssh/id_dsa
debug1: Trying private key: /home/mongo1/.ssh/id_ecdsa
debug1: Trying private key: /home/mongo1/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).