Generate and copy SSH Key

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

  1. Abu Rayane macrumors member

    Joined:
    Sep 23, 2014
    #1
    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:

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

    556fmjoe

    Joined:
    Apr 19, 2014
    #2
  3. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #3
    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 id_rsa.pub. That's the key data you need to transfer to the machine you want to log in to.
     
  4. duervo macrumors 68000

    duervo

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

    cat ~/.ssh/id_rsa.pub | 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

    Joined:
    Sep 23, 2014
    #5
    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:
    Code:
    cat ~/.ssh/id_rsa.pub | 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 604

    Joined:
    Oct 14, 2008
    #6
    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, http://stackexchange.com is a better place.
     
  7. Abu Rayane thread starter macrumors member

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

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

Share This Page