Report this

What is the reason for this report?

copy and paste into console

Posted on May 2, 2016

How do you copy and paste into the console?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I’m also finding this maddening- I need to add a new SSH key for the machine I’ve moved to, and there’s no way to easily move that information into the web console. Even creating a gist on GitHub creates a massive filename. It would be very useful to have a paste feature.

Hi, I have developed the following script based on another one, i lost its link

What I did is that I made it so it sends the whole text/cmd in one go also I added the ability to send line breaks when typing “\n” into the text, finally I made it so click enter at the end of each command.

The script is in a bookmarket format, just create a bookmarket and paste the following script into the address field

javascript: (function () {
	var s = prompt("Enter text to be sent to console, (This wont send the enter keystroke)");
	s = s.replace(/\\n/gi, String.fromCharCode(13));
	var t = s.split("");
	t.push(String.fromCharCode(13));
	console.log(t);
	var i = [];
	t.forEach(f);
	console.log(i);
	rfb._sock.send(i);
	function f(character) {
		var code = character.charCodeAt();
		var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1;
		var shift = XK_Shift_L;

		if (needs_shift) {
			key(shift, 1);
		}
		key(code, 1);
		key(code, 0);
		if (needs_shift) {
			key(shift, 0);
		}
	}
	function key(keycode, down) {
		i = i.concat(RFB.messages.keyEvent(h(keycode), down));
	}
	function h(e) {
		switch (e) {
		case 13:
			return XK_Return;
		default:
			return e;
		}
	}
})();

Hi. Easiest solution if you’re a Chrome user is to add Secure Shell or Termius or FireSSH extension and access your server via one of these console. Copy Paste Cut work fine (same on Firefox).

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.