如何用mac键盘粘贴到虚拟盒中的终端linux?

时间:2012-12-05 03:56:27

标签: linux macos terminal

我正在使用Mac,我在虚拟机上安装了debian linux。 我想将我的Mac中的URL复制到虚拟框中的终端linux。我怎么能这样做?

6 个答案:

答案 0 :(得分:23)

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

答案 1 :(得分:6)

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

答案 2 :(得分:5)

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

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

答案 3 :(得分:2)

<强>第一
安装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 64位

答案 4 :(得分:1)

我把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

此脚本对于击败愚蠢地阻止粘贴的密码字段也很有用。

答案 5 :(得分:1)

我在我的Windows机器上使用ubuntu,虚拟机与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