Host k8s-m1
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile D:/vagrant-file/file1/.vagrant/machines/k8s-m1/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
Host k8s-n2
HostName 127.0.0.1
User vagrant
Port 2200
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile D:/vagrant-file/file1/.vagrant/machines/k8s-n2/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
查看 hostname ,port,IdentityFile 这三个位置
有可能不能选择密码登录,默认是用密钥登录,浏览,文件,找到 刚刚的IdentityFile ,再输入密码vagrant 就可以使用vagrant 用户 ssh登录
root账号登录
vagrant登陆后,切换到root账号
$ sudo -i
- 1
设置root的密码
修改 /etc/ssh/sshd_config 文件,(注意,vagrant用户下这个文件是只读的,可能什么也看不见)
修改 ssd_config 里 PermitRootLogin属性 改为yes ,并把前面的# 去掉
PasswordAuthentication 改为yes 并且去掉 #
保存退出,重启sshd服务
$ systemctl restart sshd
- 1
再通过xshell连接的时候,就可以用账号密码,root来登录了
问题:虽然xshell里都是用127.0.0.1:2222或者2200 这种登录的,但是也可以使用自己设置的ip 例如192.16.25.11:22 去登录,这里用自己设置的ip时端口则是22。
设置完成以后就和自己开的虚拟机没什么两样了。
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-2b43bc2447.css" rel="stylesheet">
</div>