Ubuntu – Unable to copy text from the terminal to external programs

clipboardvim

Aim: I want to copy my public ssh key generated on AWS Server to my github account.

I have little experience with Ubuntu.
I use the ssh command from my laptop to connect to the AWS Server.
The operating system on both my laptop and AWS Server is Ubuntu trusty tar 14.04.

ssh -i /etc/ssh/aws_myhosts.pem ubuntu@XX.XX.253.101

This works.

I want to copy the contents of aws_myhosts.pem (my public ssh key) to my github account.

I can select the text using Vim (using pressing v first and keyboard arrows, no mouse is present), but can't copy and paste it to an external program (ie Github).

The problem occurs when I want to copy my public ssh key to Github.

I have installed vim-gtk as it has clipboard support. When I type

$ vim --version | grep clipboard  
+clipboard
+xterm_clipboard

I understand clipboard support is required.

It is said I should use "+y to copy text, but this has not worked.

What do I have to do to be able copy text from the terminal to external programs?

I've tried Accessing the system clipboard using Vim

Best Answer

To use the clipboard that way, you must have X forwarding enabled ssh -X (or ssh -Y, depending on the settings).

See How can I copy text to the system clipboard from Vim?.