zstackio / zstack

ZStack - the open-source IaaS software http://zstack.org (国内用户请至 http://zstack.io)
Apache License 2.0
1.3k stars 391 forks source link

创建云主机时,没有能够指定默认登录密码的功能,或者是增加ssh key的 #308

Open xuedihualu opened 8 years ago

xuedihualu commented 8 years ago

希望增加在成功安装云主机后如何免密码登录或者,如何指定初始的密码

youyk commented 8 years ago

ZStack currently support SSH key injection through cloud-init. The injection method could be referred from http://zstack.org/blog/v1.0.html#userdata http://zstack.org/blog/v1.2.html#userdata http://zstack.org.cn/index.php?m=Article&a=show&id=271

The right way to use ssh key injection. You just need 2 steps:

  1. create a VM template with standard Cloud-init service installed (you can easily find some standard VM image from internet. If not, you can just install cloud-init package and save it to a template, after install a VM OS.).
  2. using creating VM instance command like: CreateVmInstance name=vm imageUuid=d720ff0c60ee48d3a2e6263dd3e12c33 instanceOfferingUuid=76789b62aeb542a5b4b8b8488fbaced2 l3NetworkUuids=37d3c4a1e2f14a1c8316a23531e62988,05266285f96245f096f3b7dce671991d defaultL3NetworkUuid=05266285f96245f096f3b7dce671991d systemTags='sshkey::ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5x3AoWuiZawxXoBxEcOhhdVAST4kJA/cQ2zGnh3yZ/KBU+VILQHTkbNWAaRw3q0UtfpLfVj/KoPFr43qjGF+ud8B/rD7stsAvbNVdms81aBDAFZyiN7dhlwTK+XvCMhl4RxHUItm7+Y7gzb8jTHPoqlPzAw4r8enqhNf9ABG+kaXIDa0FPhVaMPoLzHWjTe34ONIBlxsY/y1Zle49vPVYS7oAHQTc7ly7bnGXffNJ18uF5M7HPUgsIDum8KICa2LmnXJeB2M9XZtXtJUdR1ZKXeQpRtikAm3G3CwFkDxWnx31dGr0lLa2aZ88LQ2iP8nb2NK58aKb4I9Aq19k44Rl root@yyy'

the systemtag part is the ssh key to be injection.

xuedihualu commented 8 years ago

thxs, My virtual machine is created, so the following operation is performed CreateSystemTag resourceUuid=7859bc697e374daebb2e29821ead396a resourceType=VmInstanceVO tag='sshkey::ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFlY2rFhOCBaPgDvtDMrw73R+9irIL489kMJ/w05llaobSPERfci4Rb2GdY8QeNCwwFicvyXGtF0WZ6T3YtBKvJIxS364pD1v+4g4Y+7+KZZ1PBcZPY2zSWA0zdwDY1EMHvumeajcYX3iMp0yjICRZ0KOkdlilYDS3w/i2knkVVh26UnxBzKn7HK/PPNjmaIPoa16Aqo/bt+CT9sEtzOR/IdkgE9v3Gs1C5T3uwWWnwZsO4E6v9iC9Bz8Q7Fd7HALwuUUUo37J1/YVASlhqk8gKBXX+viny8N9N+2Ec6MgOhx26C5Bu0gLrfZPJu3qq1TI0UkRZyEaz65W9ulRBP27 root@docker-130.com' But I still can't login error [root@docker-130 .ssh]# ssh root@192.168.10.207 Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

youyk commented 8 years ago

After create systemtag, you need:

  1. make sure cloud-init is installed in VM and set as bootstrap service.
  2. call ZStack zstack-cli command to stopVm and startVm to trigger the cloud-init.
xuedihualu commented 8 years ago

sorry,Do not know the password, can not enter the virtual machine

694982827 commented 7 years ago

windows注入密码的systemTags中的字段是什么?

youyk commented 7 years ago

windows和linux是一样的,只是你需要在Windows里面预先安装CloudInit

694982827 commented 7 years ago

谢谢! 我在windows上面装好cloud-init之后转成模板,那么请问之后创建云主机的时候需要指定systemTags也是systemTags='sshkey::ssh-rsa 用户密码 用户名'吗?ssh-rsa这个系统标签名称也适用在windows的userdata吗?

youyk commented 7 years ago

@694982827 我不认为sshkey支持 Windows登录,相关信息可以查询 cloud-init的使用方式