如何修复virtualbox的复制粘贴问题?

如何修复virtualbox的复制粘贴问题?

我在尝试将主机中的文件复制粘贴到客户机或反之时遇到问题。我尝试安装虚拟客户机,但出现以下错误。

在此处输入图片描述

你们能帮我解决这个问题吗?

答案1

免责声明: 这是一种解决方法,而不是解决方案。它适用于 Ubuntu 主机和 Ubuntu 客户端。它不适用于虚拟机端的专用网络配置。

描述:

我以前遇到过剪贴板问题,对我来说修复它太麻烦了。相反,我编写了一个脚本,它允许我使用网猫

实现它:

使用文本编辑器创建一个新的纯文本文件,内容如下。您可以将端口号从 12354 更改为任何开放端口。

#!/bin/bash
# DESC: vbox-chat allows you to send text back and forth between a VirtualBox 
#     machine an Ubuntu host. This script must be started on the host first and then 
#     on the client.
# ARGS: Pass "host" or "guest" as the first parameter when calling this script

port=12354

id="$1"
id=${id,,}
while [ $(grep -P "^(host|guest)$" <<< "$id" | wc -l) -eq 0 ]
do
    clear
    if [ "$id" == "" ]; then
        read -p "Is this the host or guest system (type host or guest): " id
        id=${id,,}
    fi
done

clear
[ "$id" == "host" ] && other="guest" || other="host"
echo -e "Type or paste text into this windo and press enter to have it show up on the\n$other machine\n"
if [ "$id" == "host" ]; then
    nc -l $port
else
    hostIP=$(route -n | grep -P "^0.0.0.0" | tr -s ' ' | cut -f2 -d ' ')
    nc $hostIP $port
fi

此脚本需要保存在主机和客户机上(我将其命名为vm-chat.sh),并且需要可执行(chmod +x /path/to/vm-chat.sh)。完成后:

  1. 在主机上,在终端中导航到你的脚本并运行./vm-chat.sh host(这必须在来宾实例之前启动)
  2. 在客户机上,在终端中导航到您的脚本并运行“./vm-chat guest”(这必须在主机实例之后启动)

现在,您可以在主机的终端窗口中键入(或粘贴)任何内容,按下回车键,它将立即传输到客户机的终端窗口。同样,您可以在客户机的终端窗口中键入(或粘贴)任何内容,按下回车键,它将立即传输到主机的终端窗口。

显然,这只适用于文本。如果您希望能够复制和粘贴文件,可以先将它们转换为 base64,但这可能不是传输文件的最佳方式。

警告:所有文本均以纯文本形式在主机和客户机之间的虚拟网络上传输!

相关内容