标签:xml compute 00000380 instance ssh 虚机 openstack root
问题: 在云环境中用户上传了一个image 镜像,但是不清楚镜像的用户名和密码,无法ssh 登陆到虚机内部。尝试通过openstack keypair 方式配置后,也是无法免密登陆到虚机。
解决过程及方法记录:
1. 通过keypair创建出虚机可以ping通,ssh 登录失败
nova boot --flavor 1104 --image volume_vm_img-nfs-1 --nic net-id=964f8071-70ac-4d27-92ca-673135568e35 --availability-zone az1:ca-compute-0-2.internal.ca.fuel --key-name nfs_key nfs-server-1
通过密钥登陆提示拒绝
2. 通过nova show + 虚机名 可以查看到虚机创建在那台节点,虚机的实例名
3. 登录虚机所在的计算节点,查询虚机,准备设置让虚机可以virsh console
compute-0-2:~# virsh list
Id Name State
----------------------------------------------------
11 instance-00000371 running
12 instance-0000036e running
15 instance-0000037d running
17 instance-00000380 running
4. 先暂停计算节点的nova-compute 服务,关闭虚机
root@compute-0-2:~# service nova-compute stop
root@compute-0-2:~# virsh destroy instance-00000380
Domain instance-00000380 destroyed
5.编辑实例的xml 文件
root@compute-0-2:~# virsh edit instance-00000380
将图1 的白色部分内容放置图2 位置(,放在</interface>下,<serial type='file'>上)保存退出
6.重新定义实例的xml 文件,启动实例
root@compute-0-2:~# ls /etc/libvirt/qemu/
instance-0000036e.xml instance-00000371.xml instance-0000037d.xml instance-00000380.xml networks
root@compute-0-2:~# virsh define /etc/libvirt/qemu/instance-00000380.xml
Domain instance-00000380 defined from /etc/libvirt/qemu/instance-00000380.xml
root@compute-0-2:~# virsh start instance-00000380
Domain instance-00000380 started
7. Console 登录到虚机里,修改配置 /etc/ssh/sshd_config 文件,设置运行root登陆
root@compute-0-2:~# virsh console instance-00000380
Connected to domain instance-00000380
Escape character is ^]
root@host-192-168-20-12:~# vim /etc/ssh/sshd_config
...
#PermitRootLogin without-password
PermitRootLogin yes
PasswordAuthentication yes
PermitEmptyPasswords yes
...
修改设置root 密码(r00tme)
root@host-192-168-20-12:~# passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
重启ssh服务
root@host-192-168-20-12:~# systemctl restart ssh.service
Ctrl + ] 退出登录
8. 在compute节点上恢复nova-compute 服务
root@compute-0-2:~# service nova-compute start
通过命名空间登录虚机 Ip netns list 查看当前的命名空间 虚机使用的是那个net-id 我们登录用相对应的命名空间(qdhcp-(net-id))
qdhcp-964f8071-70ac-4d27-92ca-673135568e35
root@control-node:~# ip netns exec qdhcp-964f8071-70ac-4d27-92ca-673135568e35 ssh 192.168.20.12
root@192.168.20.12's password:
Last login: Mon May 11 21:38:49 2020
root@host-192-168-20-12:~#
标签:xml,compute,00000380,instance,ssh,虚机,openstack,root 来源: https://www.cnblogs.com/yk0625/p/14092078.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。