【问题标题】:How to paste to terminal linux in virtual box with mac keyboard?如何使用mac键盘粘贴到虚拟框中的终端linux?
【发布时间】:2012-11-22 20:30:27
【问题描述】:

我使用的是 Mac,并且在虚拟机上安装了 debian linux。 我想将一个 URL 从我的 Mac 复制到虚拟框中的终端 linux。我该怎么做?

【问题讨论】:

  • 它是终端模拟器窗口,还是实际终端? (如果是前者,打开剪贴板共享,然后按 Command+Shift+C。)
  • 您安装了来宾添加吗?另外,您说的是 TTY 窗口还是终端模拟器?
  • 我无法安装来宾添加,因为我的 debian 没有 X.Org。我直接使用 TTY。
  • 有一个similar question on Super User,但不幸的是,没有比“使用 SSH”更好的答案了。

标签: linux macos terminal


【解决方案1】:

有时,在 Mac 上打开终端然后通过 SSH 连接到 VirtualBox 来宾会更容易。这避免了很多改变焦点等的麻烦。

【讨论】:

    【解决方案2】:

    我也遇到了同样的问题。确保剪贴板共享打开后,Ctrl+Shift+V 粘贴到 debian 的终端中。

    【讨论】:

      【解决方案3】:

      我刚刚写了一个指南,让我在 VirtualBox 上在 OS X 和 Ubuntu 之间进行复制和粘贴,因为它让我很沮丧。也许对遇到这个问题的人有帮助:

      http://blog.nostopbutton.com/2013/08/24/setup-copy-and-paste-between-os-x-and-linux-virtualbox/

      【讨论】:

      • 您的教程讨论了 X 下的复制和粘贴,而 OP 询问的是没有 GUI 的 Linux 控制台。
      • 找到了!它正在调整应用程序中
      【解决方案4】:

      第一
      安装 Guest Additions CD (Devices->Insert Guest Additions CD image)。

      激活剪贴板共享
      然后重新启动后,在 Virtualbox 中转到 Machine->Settings->General->Advanced 并设置
      Shared Clipboard: Bidrectional

      更改 VirtualBox 主机密钥
      Vitualbox/Preferences/Input/Virtual Machine/Host Key Combination
      选择不同的然后

      键映射
      对于我的cmd/ctrl 映射,添加英文(Macintosh)键盘似乎是最舒适的解决方案:)

      转到Ubuntu Settings->Text Entry
      (我猜在旧版本中它可能在键盘布局设置中)
      Input sources to use:下打加号(+)
      添加English (Macintosh)

      我在 VirtualBox 5.0.4 中使用 Ubuntu 14.04.3 LTS 64bit

      【讨论】:

      • 问题是关于使用 TTY,而不是使用终端模拟器的完整桌面安装。
      【解决方案5】:

      我已经整理好了a page describing how to do this

      简短的版本是您可以使用 AppleScript 和自定义键盘快捷键来执行此操作。

      AppleScript:

      on run {input, parameters}
          set input to input as text
          tell application "System Events"
              repeat with currentChar in the characters of input
                  set cID to id of currentChar
                  set used to false
                  repeat with r in {{48, 29}, {49, 18}, {50, 19}, {51, 20}, {52, 21}, {53, 23}, {54, 22}, {55, 26}, {56, 28}, {57, 25}, {45, 27}, {46, 47}, {47, 44}, {61, 24}}
                      if first item of r is equal to cID then -- 0-9 -./=
                          key code (second item of r)
                          set used to true
                      end if
                  end repeat
                  repeat with r in {{42, 28}, {43, 24}} -- *+
                      if first item of r is equal to cID then
                          key code (second item of r) using shift down
                          set used to true
                      end if
                  end repeat
                  if not used then
                      keystroke currentChar
                  end if
              end repeat
          end tell
          return input
      end run
      

      这个脚本也可以用来解决愚蠢地阻止粘贴的密码字段。

      【讨论】:

        【解决方案6】:

        我在我的 windows 机器上使用 ubuntu,virtualbox 与 PuTTY、FileZilla 等连接。

        (不使用默认的虚拟机控制台)

        以下是您可以从头开始设置的方法:

        ### Setup Virtualbox:
            https://www.virtualbox.org/wiki/Downloads
            install ubuntu from their website
        ### Launch Ubuntu from Virtualbox Console:
            sudo apt-get install openssh-server
            sudo systemctl start ssh
            sudo systemctl status ssh
            netstat -tulpn
                # see ubuntu port 22 open and ssh running
            sudo poweroff
        ### Virtualbox: 
            settings - network - Advanced - Adapter Type: PCNet Fast 3 - Port Forwarding
            Name: SSH, Protocol: TCP, Host Port (Windows): 3022, Guest Port (Ubuntu): 22
            right click - start - headless start
        ### PuTTY: 
            Seesion: Localhost Ubuntu: <your_user> -p
                Host: <your_user>@127.0.0.1
                Port: 3022
            Window - Colums: 130, Rows: 24
            Scrollback lines: 10000
            Appearance - Cursor: Vertical + Blinks
            Font Courier New  - Regular - 12px
            Behaviour - Window Title: Localhost Ubuntu
            Full screen on ALT + ENTER
            Connection Data - Auto login Username: <your_user>
            Session - SAVE!
        
        ### FTP:
            Host: localhost 
            Port: 3022
            SFTP (SSH FTP)
            Logon Type: normal
                <your_user>
                <pass>
            Transfer settings: limit max. conenction: 4
        
        ### Git BASH:
            ssh -p 3022 <your_user>@localhost
        
        ### Enable SSH Root Login: (Use only on localhost, security advice!)
            # Set a password for root account first and then enable root account:
                sudo passwd root
                sudo passwd -u root
                # Reverting Back: (lock the root account)
                    sudo passwd -l root
            # Enable SSH root login:
                sudo nano /etc/ssh/sshd_config
                    # PermitRootLogin prohibit-password
                    PermitRootLogin yes
                sudo systemctl restart ssh
        
        ### Virtualbox Windows Headless Start
            # Make a .lnk shortcut with target or .bat batch file
            "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "UbuntuMin" --type headless
            "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "UbuntuMin" poweroff
            Add shortcuts to start menu -> ubuntu START & STOP - change .ico - right click - pin to start
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-10-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-03-14
          • 1970-01-01
          • 1970-01-01
          • 2012-07-17
          相关资源
          最近更新 更多