21

I'm following Github's instructions for adding an SSH key. I've generated the id_rsa.pub file from my AWS EC2 instance, but I cannot complete the step that has me copy the contents of the file using xclip because I cannot install xclip onto the EC2 instance.

  1. I tried to install xclip on the EC2 instance using sudo yum install xclip, but that didn't work ("No package xclip available").
  2. So I looked around and found more detailed install instructions, but they didn't work either ("curl: (22) The requested URL returned error: 404 Not Found"), and the suggested correct URLs in the comments also failed.
  3. (I also tried just copying the text contents of the id_rsa.pub file using Putty and ctl-c, but Github declared the resulting key invalid.)

So, how do I install xclip on 64-bit Amazon Linux AMI 2012.09?

Jeromy French
  • 11,812
  • 19
  • 76
  • 129

4 Answers4

39

I needed this today for a file larger than a ssh-key, and cat was not enough. You need to enable the EPEL repo in EC2 in order to get xclip:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm
sudo yum-config-manager --enable epel
sudo yum install xclip -y
15

You don't need xclip. Just ssh into the EC2 instance and cat the key to your terminal, then copy and paste it from your terminal to wherever you need it.

Unknown
  • 5,722
  • 5
  • 43
  • 64
  • Using `cat` worked. Now just need github to document their SSH steps. – Jeromy French Oct 31 '12 at 21:30
  • 43
    Not an answer to the question – Ordiel Oct 27 '16 at 00:22
  • you can't use `cat` all the time the cases actually. what if you want to copy a large file? – Yar Aug 01 '17 at 23:11
  • 1
    @Yar obviously, but the initial question was about a ssh key, which is small. If you need to transfer larger files, scp is the way, or if that's not possible, maybe zmodem. – Unknown Aug 02 '17 at 08:24
  • 4
    I agree, not an answer to the question. I need to copy a different, large buffer to the clipboard – Alan Oct 12 '17 at 06:47
  • Using `xclip` is convenient even over `ssh`. Here's an example - https://github.com/tmux/tmux/wiki/FAQ#how-do-i-copy-a-selection-from-tmux-to-the-systems-clipboard . And it works perfectly if you `ssh -X`. – Victor Yarema Mar 30 '20 at 11:30
6

Use

sudo amazon-linux-extras install epel -y
sudo yum install xclip -y

Source: https://gist.github.com/kevin-kientopp/7a1dee73ab0f1bdb21fe158407a028ea

srgsanky
  • 671
  • 1
  • 11
  • 16
3

I don't mean to wake up the zombies but in case someone is still wondering you can wget the rpm (i.e. from here) and then

sudo yum localinstall xclip-0.12-1.el6.x86_64.rpm

Note: you may need to do the same for some dependencies.

Victor Yarema
  • 1,183
  • 13
  • 15
Ordiel
  • 2,442
  • 3
  • 36
  • 52