Generate and copy SSH Key

Discussion in 'MacBook Pro' started by Abu Rayane, Oct 17, 2014.

  1. Abu Rayane macrumors member

    Sep 23, 2014
    Hello everybody,

    I generated a SSH key on my MacBook Pro, then I would like to copy it to an Ubuntu server, using the below command line, it DOES NOT work:

    ssh-copy-id host
    -bash: ssh-copy-id: command not found
    Thanks in advance
  2. 556fmjoe macrumors 65816


    Apr 19, 2014
  3. mfram macrumors 65816

    Jan 23, 2010
    San Diego, CA USA
    I have never heard of 'ssh-copy-id'. Must be a script someone created. Go into your ~/.ssh directory. In there will be the file. Assuming you created an RSA key, the file will be That's the key data you need to transfer to the machine you want to log in to.
  4. duervo macrumors 68020


    Feb 5, 2011
    Should be posted in the OS X forum, not the MacBook Pro one. Anyway ...

    cat ~/.ssh/ | ssh user@ssh_server "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"

    If you do not understand what this does, then I suggest further learning before you use command-line for anything else, or else you risk doing some serious damage to your system(s) (not physical damage ... just damage to OS installation that may require (worst case) a reinstall of the OS and/or restore from backup.)
  5. Abu Rayane thread starter macrumors member

    Sep 23, 2014
    well, I usually use Ubuntu command line, so I think it is quite similar commands.

    Here I am using a different port to connect using SSH, and the folder ssh is already there:
    cat ~/.ssh/ | ssh 'USER@IP -p PORT' "cat >> ~/.ssh/authorized_keys"
    ssh: Could not resolve hostname IP -p PORT: nodename nor servname provided, or not known


    I used the Ubuntu command line to copy id


    The page failed to open
  6. leman macrumors G3

    Oct 14, 2008
    I suggest you ask the IT support of your server for help. The command that duervo has shown you is correct, it only needs some minor tweaks to work for you. If you are not able to figure it out by yourself then you should leave it be until you can learn the basics of unix shell, unless you want to risk messing up your server installation, or your computer, or both.

    At any rate, this does not belong on these forums. If you want community help, is a better place.
  7. Abu Rayane thread starter macrumors member

    Sep 23, 2014
    well, I removed the quotes from the syntax and it works:

    cat ~/.ssh/ | ssh USER@IP -p PORT "cat >> ~/.ssh/authorized_keys"
    Thanks for your help

Share This Page