Search code examples
githubvirtualboxssh-keysubuntu-18.04

How to get public ssh key from headless Ubuntu Server (no gui) to github deploy key


I have built a headless Ubuntu Server 18.04 (without GUI). This is a simulated environment built in VirtualBox meant to simulate a production scenario that I am faced with configuring very soon. The production environment will be remote and access via a VPN. Please notes that VirtualBox is not part of the production scenario.

I have created a private/public ssh key pair for using in GitHub so I can add a new deploy key

I need to be able to get a copy of the public key to add to GitHub.

There is no clipboard with a headless server via terminal. I tried installing and configuring xclip/xsel to behave like pbcopy/pbpaste. This works great on Ubuntu with a GUI but doesn't work on a headless server via terminal.

Trying to use xclip like this:

DISPLAY=:0 xclip -sel clip < ~/.ssh/id_rsa.pub

results in:

Error: Can't open display: :0

I tried getting OpenSSH up and running. I'm not an SSH guru and haven't gotten that to work.

Are there any other ways to get that ssh public key from the headless server? It is a remote server with no physical access.


Solution

  • My solution: I ended up ftp'ing the public key to a remote server. It's a hack but worked.