重庆思庄Oracle、Redhat认证学习论坛

标题: openstack 通过ssh-key方式登陆云主机 [打印本页]

作者: 郑全    时间: 2017-11-3 13:16
标题: openstack 通过ssh-key方式登陆云主机
在创建实例时,保存好私钥,后面客户端访问这个实例时 ,要使用前面创建的私钥.默认通过密码是不能访问的.

在客户端访问时,先把私钥保存为一个文件,比如我通过 一个机器登陆客户端,
1.先在客户端创建私钥文件 vi /root/key.pem,

下面是一个例子 :
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAxYCj9fybT8Y0Hgul4NE/NXFxkRY3zBGTvDN1T8NVsKz7LA58
0IIagYWP1ekHTMMU5BB9EOH88ov24wSYmmFlzF9KXF2kz5pni6oq2LH/uR5p7cie
BR09iWO9o3IbtOYv1lxrU3Jg0cOCrhRpdtjz5149+6w45mk4ftIm9L6ZI5M48UQW
xc602YXV/QngG+GPclpSCZXkX2NW2Yqyf1XsHs/hsnxqA0nuKYrqvJfAorE73907
n7dZ48vWNO/mHn+gcz6ZO00tREpkqUMmKNMcIOMcPeVrhFLDnRcYHn+oZhyWrzoT
TSWMJlZF2qCFS5WvMv5onzwUzFuhjKBT2x/R5wIDAQABAoIBAAZ8OuYQ7WipMXzr
FP9U36Z5mykQebSRvzAm4GtGFsI+a+D+eMq/+u7V2+tCQ6MZpM34XKL5SL0OK4U4
2Wn4WMdlOaPez1Kh11SWueFzttn1TbUpKUcxtpuUUt3TGWXPSTLYxg1vbA53RQtC
UFQ+u4OVbKOe/B9UxS4k6HKQ76ZjWG0X4eWU/vAr6Yg5KRMRez/rsMwRglI+uKBX
n86RRlKn7ecIItJpwVDjmT20nv5xf1lUVEfsW+wnnxWofNMNXuZWqFeMg/8DLmEO
+dy2EWtuiYvf5ViLUqZb2s69gkuZcyLvYAA/GkOOIN/nznWSvoAQ9+02MpPAy5ZK
1lL1NoECgYEA5/TLzyMWUEJxIWMoFSRocrj0XI2zW1ZBXxdxAKRhLzJQVdAOzsLI
mBvkOFsbW9xhxJX4XmYPqyZWrlF+8TVc3WH7jCYeHDOKx+c9xdCSfafGtVMxnRm4
TPC8IVh/0dSgjod4Rw/WaTZEJJVKtp3WGQY67Ng16SvEfvE0s7Q8tF8CgYEA2fmT
/5wwt7kAhIaHOsLTuKG7hiq35s4BRPSCXGt7SzUIhVirPqLvSV31bqgp/aEi//5G
OBR2sJUQ2EWDsd9boVFQiA/Y/pBe2hy+mujqPTlansdRo4nt1LBXBL1li0EZNVBh
VF+tDa9PdjQfwarADcBWCr6upEH5PGkrUHlDD3kCgYEAlrfhln5eCVii2ebsLJCz
rZewcFNCr56ka31318r3uwseWCQQ+xhl7zBwYo4QgOf6PxqTgAMhOzx2Jl6d9W2P
IeqA4NgDyJ9VFf+Ti+2ywiM6YqfkHQiRUK08EQ7IPzfB+9ratJH95+9y57J6EZ8N
dsUtlKgIn7How/NHI12B9FECgYA49fVs6H36pMez2gvgmSUGrIz6hJNGJzNBt7uR
Ny0i/Brb7c3iMmXhgEIwxpUiiEdDKkljQkW541phidjeVIX3Y+5tf+aurz96M+TD
SnZbxW8e6us0l0ilOeejf3LXrw1NV1H34ICygMt9EiXyUBKcBVT2vdmZZvwgg0Mk
ZmvV0QKBgQDjDEFxv4XTRmdY4qXCfQfPGldO7HHvWt0sLXLGdaf3OgcFoMwLdhR2
PmDdfq91Jhiy8pbuQo3ryFMZSz/W0xIA6SXRVKw/SWBtal3sjLj+iytusQm0EqfM
Ra3+4JwlsK5ku/gxqIQFvuDoFM1HdZfjV2aIO6qvnBZxE8AkFYevrQ==
-----END RSA PRIVATE KEY-----

2.之后,修改这个私钥的权限为700

chmod 700 /root/key.pem

3.通过ssh 私钥对登陆

ssh -i /root/key.pem centos@192.168.133.43

192.168.133.43是虚机(实例)的浮动ip

之后,就登陆到这个虚机上面去了 .







欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2