Vagrant+Secure CRT的使用

实际上,大家通过查看自动生成的配置文件:Vagrantfile  知道以下配置方式

一、Vagrant默认的三种网络配置

一种是端口映射,第二种是私有网络,第三种是公有网络。
(1)端口映射 

配置一个端口映射的规则,然后访问指定的端口,VAGRANT会转发到虚拟机端口上处理。配置方法如下:

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port  名为guest的虚拟机80端口映射宿主机host的8080端口

   config.vm.network "forwarded_port", guest: 80, host: 8080


(2)私有网络

配置一个私有的IP地址,用于宿主机和虚拟机之间的访问,如果多个虚拟机设置的是相同的网段,那么虚机可以互相访问。

# Create a private network, which allows host-only access to the machine
# using a specific IP.

   config.vm.network "private_network", ip: "192.168.33.18"

 

(3)公有网络

设置公有网络,不仅仅是宿主机可以访问,它也拥有一个静态的IP,这样整个网段的人都可以访问VAGRANT创建的虚拟机。

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.

   config.vm.network "public_network", ip: "192.168.33.18"

二、SecureCRT连接示例:使用的是私有网络方式

(1)vagrant halt  重启虚拟机
(2)Vagrantfile文件中添加下列配置
   config.vm.network "private_network", ip: "192.168.33.18"
(3)vagrant up

 

 

(1)本地连接为  127.0.0.1 端口为2222。口令用户名密码为vagrant

 

 

 

 

 

 

(2)使用配置的私有网络地址连接  192.168.33.18  端口为 22

在用SecureCRT连接的时候一直报Permission denied (publickey,gssapi-keyex,gssapi-with-mic)。这里总是要找public key。而默认我们使用vagrant ssh都是免密码登陆的。为了避免这个麻烦,需要将/etc/ssh/sshd_conf中的PasswordAuthentication no改为PasswordAuthentication yes。同时设置下vagrant的密码。就可以通过192.168.33.18登陆了。

 

 

 

 

posted @   阿圆这个程序媛  阅读(624)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示