8

Friends Im trying to copy the ssh key on to the clipboard and while on the git bash, Im getting

$ clip < ~/.ssh/id_rsa.pub
sh.exe": clip: command not found

Im using Win7 , I tried using the windows command prompt but no luck,

Please let me know any alternate way

3
  • This doesn't really have anything to do with git or GitHub; it's just about clip.exe not being in your path.
    – Cairnarvon
    May 27, 2013 at 12:21
  • Thanks , any idea adding clip.exe to the path ?
    – ronan
    May 27, 2013 at 12:33
  • open a normal cmd.exe, cd to your .ssh folder and "clip <id_rsa.pub" May 27, 2013 at 13:47

2 Answers 2

12

clip.exe should be in C:\Windows\System32\ or C:\Windows\SysWOW64\. You can check if those folders are in your path by doing echo $PATH. If they aren't (which would surprise me), you can add them:

$ export PATH="$PATH:/c/Windows/System32:/c/Windows\SysWOW64"

It's probably more likely clip.exe doesn't exist on your system at all.

However, there's a much simpler way you can manipulate the Windows clipboard from Git Bash (or, for that matter, Cygwin): the clipboard device file, /dev/clipboard.

To write to it:

$ echo "test" >/dev/clipboard

To read from it:

$ cat </dev/clipboard

The equivalent of your command would be:

$ cat ~/.ssh/id_rsa.pub >/dev/clipboard
1

This is an old question, but for what it's worth...

I'm running Windows 10 with WSL 2 all configured and I found that clip.exe is present on my system at C:\Windows\System32\ and my path does already include C:\Windows\System32\. All I needed to do was to add .exe to the command in this obvious (to me, anyway) location:

clip.exe < ~/.ssh/id_rsa.pub
1
  • 1
    I also use Windows 10 with WSL 2 and your suggestion helps.
    – ikhvjs
    Oct 4, 2021 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.