Question

copy and paste into console

How do you copy and paste into the console?

Show comments

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I had a machine crash, and needed to setup another one with SSH access. I got the console login ok, but no way to paste my public key there. Just spent a whole day trying to find a way to do this.

My solution, finally was to put the public key on a public dropbox folder, then in the console, use:

curl 'https://dl.dropbox.....' > temp1
cat temp1 >> .ssh/authorized_keys

The attached JS snippet never worked for me, and I didn’t have the patience to debug/improve the snippet (maybe that was a mistake since I wasted a whole day). Some versions drop characters, some changed them, some capitalize during the script paste action.

I might understand security issues which caused DO to decide not to allow copy-paste in the console, but they must supply an alternative way to upload an SSH key.

This issue is from 2013. It’s about time DO solved this. Thanks.

What I can share is how to paste command lines in the console.

  1. Copy the console URL and paste it to a new window. ex. https://cloud.digitalocean.com/droplets/111111111/console?no_layout=true.

  2. Open Developer Tools then click Console tab

  3. Copy and paste the codes below. Taken from stackoverflow

var sendString = (function(rfb, force, sendDelay) { 
  sendDelay = sendDelay || 25;
  var _q = [];
  var _qStart = function() {
    var chr = _q.shift();
    if (chr) {
      rfb.sendKey(chr);
      setTimeout(_qStart, sendDelay);
    }
  };
  var _qStop = function() { _q.length = 0; };
  var fn = function sendString(str) {
    _qStop();
    str = str || '';
    var chr;
    for (var i=0; i < str.length; i++) {
      chr = str[i].charCodeAt();
      _q.push(chr);
    }
    _qStart();
  };
  if (rfb.sendString && true !== force) {
    console.warn('rfb.sendString not installed because it already exists.  Use force if you\'d like');
  }
  else {
    rfb.sendString = fn;
  }
  return fn;
})(rfb);
  1. On the same console type sendString(“Commandline to be pasted in the console”)

Let’s try to REQUIRE DIGITAL OCEAN to change it’s UGLY interface: no one works today without copy/paste.