pjpark
By:
pjpark

copy-paste doesn't work from your console

February 4, 2017 5.1k 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.

8 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)

Have another answer? Share your knowledge.