copy-paste doesn't work from your console

February 4, 2017 12.6k views
DigitalOcean Ubuntu

How the heck do I copy or paste anything from the web console? I've tried both Safari and Chrome. I'm trying to get ssh to work but I can't copy/paste keys or get authorized any other way.

1 comment
  • Friends after ~40 min of frustration trying to copy-and-paste my original password on my first login from my Chromebook, I found an easy solution.

    1) Install the "Secure Shell" chrome extension
    2) run it, enter your droplet's IP and username as "root"
    3) connect
    4) now for the trick: copy your password as it came on the email, and to paste it do not use CTRL-V but CTRL-SHIFT-V

    done!!!

14 Answers
pjpark February 4, 2017
Accepted Answer

I got it. I just needed to ssh in as root to set everything up.

  • @pjpark

    Glad you were able to get things working!

    For future reference, on most OS's, root is the default user you'll need to use to login initially. CoreOS is one exception.

    If you run in to any other issues, feel free to reply and I'll be more than happy to help!

@pjpark

If you're on a MacBook / MacBook Pro, the best option is to use Terminal or Hyper -- on Windows, it's best to use PuTTy.

The console that's available through the DigitalOcean Control Panel requires that you type in input -- you won't be able to CMD+V or CTRL+V it in.

You know how I got this to work after not finding any workable solution?? Logged into console, edited ~/.ssh/authorized_keys using NANO and manually typed out the new ssh key...

Was locked out due to disabling password authentication and Permission denied (publickey).

On a Mac, wrote an AppleScript to type.

In Script Editor located /Applications/Utilities/Script Editor

tell application "System Events"
    set textToType to "ssh-rsa AAAAB..."
    delay 20
    repeat with i from 1 to count characters of textToType
        keystroke (character i of textToType)
        delay 0.6
    end repeat
end tell

Make sure to have ~/.ssh/authorized_keys already open in an editor and in insert mode waiting to type

Press play

After a 20 second delay (hopefully, enough time to change to the console browser window ready for the typing to start) this will type the text inside set textToType to emulating keystrokes

That's the point. I can't do any of that stuff because I can't get ssh to work, and I can't try to get the keys to work manually because I can't copy or paste.

I've had to manually type in my local machines public ssh key from the DigitalOcean web console as well and it sucks. There's no other way as far as I'm aware if you've disabled password authentication on your server.

Haha, Wooot! I did it! Finally logged in!!
"Achievement unlocked"

Here's a python script you can use client-side to type for you...

#!/usr/bin/env python3
import subprocess
import time
import sys
text = "ssh-rsa tvHiU_VERY_LONG_KEY_sadf== you@gmail.com"

# 3 seconds to alt-tab to correct window after running
time.sleep(3)

for ch in text:
    # type out the text
    subprocess.call(["xdotool", "type", ch])
    # increase or decrease the time below to type slower or faster
    time.sleep(0.15)

Hi @pjpark, and others who reach this question from Google.

Regarding the question about pasting in the web console, you can use the script from here:
https://gist.github.com/croepha/7b53f211ae4be3c526c3 (by croepha)

Simply paste one of the versions into the browser developer console, and you'll be prompted with a textbox to paste your text into it, and aftrer that press enter in the console.

You'll see there also a version that binds the prompt to ctrl+shift+v or command+shift+v on keyboard.


There's also a revised version of the gist:
https://gist.github.com/byjg/a6378edb420a1c654c5f27bb494ca1c8 (by byjg)

This one claims to include some improvements, and creates a "sendString" function which does the same action
After you paste it into the console, you can use the command this way:

sendString('command text to be sent');

You can easily create in your browser a bookmarklet from the minified version of each of the gists (with a "javascript:" prefix).

Hello

Se this video from Sebastien

Hope this may help!

Hey everyone,
I am a product manager here at DigitalOcean and I wanted to send a quick update about this issue. We just released the ability to paste text into our Cloud Console! Give it a try and let us know if there is anything else we can help with.
Thanks,
Keith

How can DO be so widely recommended and yet in August of 2018 (September now) I get reverse capitalization when trying to paste in my SSH key (or anything for that matter) via the console. I just don't get these guys, it's one thing after another and yet everywhere you look says their stuff don't stink. Aggravating, typing in the key by hand, this just isn't worth it.

  • Totally frustrating. I had the same experience with reverse capitalization and the whole thing being truncated in half (4096 ssh key). I was able to paste my key in a "line" at a time. It seems the string buffer for the paste can't handle much so you can't overload it with too long a string. I pasted about 100 characters or less at a time into the console and it worked. Although for some reason missed the very first 'S' but I was able to catch that.

Same problem here: Reversed capitalisation; Cannot Copy/Paste.
Why am I having problems I had during the 1980's on DEC Terminal on a 2400 baud modem?
Very frustrating.
Just trying to update my authorized_keys since SSH gives "Permission denied (public key)".

I still can't copy and paste into the console. I need to update my authorized keys and what should take 2 minutes is taking more than an hour, with still no resolution in sight.

Edit: What I ended up doing was copying my idrsa.pub to a public server, wgeting it to my DO, and then yanking and pasting into `~/.ssh/authorizedkeys` with vim.

Have another answer? Share your knowledge.