如何使用mac键盘在虚拟框中粘贴到终端linux?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13716043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to paste to terminal linux in virtual box with mac keyboard?
提问by ggomesfe
I'm using Mac and I've installed debian linux on virtual box. I want to copy a URL from my Mac to terminal linux in virtual box. How can I do that?
我正在使用 Mac,并且在虚拟机上安装了 debian linux。我想将一个 URL 从我的 Mac 复制到虚拟框中的终端 linux。我怎样才能做到这一点?
采纳答案by Alan Porter
Sometimes, it's just easier to open a terminal on the Mac and then SSH to the VirtualBox guest. That avoids a lot of the hassle of changing focus, etc.
有时,在 Mac 上打开终端然后通过 SSH 连接到 VirtualBox 来宾会更容易。这避免了很多改变焦点等的麻烦。
回答by Joseph Sheedy
I just had the same problem. After making sure Clipboard Sharing is on, Ctrl+Shift+V to paste into the terminal in debian.
我只是遇到了同样的问题。确保剪贴板共享打开后,Ctrl+Shift+V 粘贴到 debian 的终端中。
回答by nostopbutton
I just wrote up a guide to getting copy-and-paste working between OS X and Ubuntu on VirtualBox as it had been frustrating me. Maybe of help to someone who comes across this question:
我刚刚写了一个指南,让我在 VirtualBox 上在 OS X 和 Ubuntu 之间进行复制和粘贴工作,因为它让我很沮丧。也许对遇到这个问题的人有帮助:
http://blog.nostopbutton.com/2013/08/24/setup-copy-and-paste-between-os-x-and-linux-virtualbox/
http://blog.nostopbutton.com/2013/08/24/setup-copy-and-paste-between-os-x-and-linux-virtualbox/
回答by Allisone
First
Install Guest Additions CD (Devices->Insert Guest Additions CD image
).
首先
安装 Guest Additions CD ( Devices->Insert Guest Additions CD image
)。
Activate clipboard sharing
Then after a reboot, in Virtualbox go to Machine->Settings->General->Advanced
and setShared Clipboard: Bidrectional
激活剪贴板共享
然后重新启动后,在Virtualbox中转到Machine->Settings->General->Advanced
并设置Shared Clipboard: Bidrectional
Change VirtualBox Host Key
In Vitualbox/Preferences/Input/Virtual Machine/Host Key Combination
choose sth different then ?
更改 VirtualBox Host Key
InVitualbox/Preferences/Input/Virtual Machine/Host Key Combination
选择不同的然后?
Key Mapping:
For the cmd/ctrl
mapping for me adding the English (Macintosh) keyboard seems to be the most comfortable solution :)
键映射:
对于cmd/ctrl
我的映射,添加英语(Macintosh)键盘似乎是最舒适的解决方案:)
Go to Ubuntu Settings->Text Entry
(I guess in older versions it might be in Keyboard Layout Settings)
Under Input sources to use:
hit plus (+)
add English (Macintosh)
转到Ubuntu Settings->Text Entry
(我猜在旧版本中它可能在键盘布局设置中)
在Input sources to use:
点击加号(+)下
添加English (Macintosh)
I'm on Ubuntu 14.04.3 LTS 64bit in VirtualBox 5.0.4
我在 VirtualBox 5.0.4 中使用 Ubuntu 14.04.3 LTS 64 位
回答by Eric
I've put together a page describing how to do this
我已经整理了一个页面来描述如何做到这一点
The short version is that you can do this using AppleScript and a custom keyboard shortcut.
简而言之,您可以使用 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
This script is also useful for defeating password fields which foolishly prevent pasting.
该脚本对于破解愚蠢地阻止粘贴的密码字段也很有用。
回答by Tarik
I use ubuntu from my windows machine with virtualbox connected with PuTTY, FileZilla etc.
我在我的 Windows 机器上使用 ubuntu,虚拟机与 PuTTY、FileZilla 等连接。
(Not using default virtualbox console)
(不使用默认的虚拟机控制台)
Here is how you can setup yours from scratch:
以下是您可以从头开始设置的方法:
### 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