Skip to content

Instantly share code, notes, and snippets.

@jcanfield
Last active December 11, 2015 01:18
Show Gist options
  • Select an option

  • Save jcanfield/4522006 to your computer and use it in GitHub Desktop.

Select an option

Save jcanfield/4522006 to your computer and use it in GitHub Desktop.

Revisions

  1. jcanfield revised this gist Jan 13, 2013. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -6,17 +6,18 @@
    # I typically create the script in my ~/.bin and symbolically it to my /usr/local/sbin.
    # $ touch ~/.bin/copykeys.sh
    # $ chmod +x ~/.bin/copykeys.sh
    # $ nano ~/.bin/copykey.sh
    # $ nano ~/.bin/copykeys.sh
    # $ sudo ln -s /home/yourusername/.bin/copykeys.sh /usr/local/sbin/copy-ssh-key

    #!/bin/bash
    #!/bin/bash

    echo "Copying local SSH Key to $1..."
    echo "Example Usage: copykeys [email protected]"
    cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> .ssh/authorized_keys"
    echo "Your Public SSH Key was copied to $1."
    echo "Copying local SSH Key to $1..."
    echo "Example Usage: copy-ssh-key [email protected]"
    cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> .ssh/authorized_keys"
    echo "Your Public SSH Key was copied to $1."

    exit
    exit

    # Second Method is use the Copy Keys script available via the Repositories (Debian/Ubuntu0

    ssh-copy-id <username>@<host>
    ssh-copy-id <username>@<host>
  2. jcanfield created this gist Jan 13, 2013.
    22 changes: 22 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Copy SSH Keys to Remote Server (for password-less access)
    #
    # More information copying SSH Keys to remote servers can be found at, https://help.ubuntu.com/community/SSH/OpenSSH/Keys.

    # Method One is to create a simple script.
    # I typically create the script in my ~/.bin and symbolically it to my /usr/local/sbin.
    # $ touch ~/.bin/copykeys.sh
    # $ chmod +x ~/.bin/copykeys.sh
    # $ nano ~/.bin/copykey.sh

    #!/bin/bash

    echo "Copying local SSH Key to $1..."
    echo "Example Usage: copykeys [email protected]"
    cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> .ssh/authorized_keys"
    echo "Your Public SSH Key was copied to $1."

    exit

    # Second Method is use the Copy Keys script available via the Repositories (Debian/Ubuntu0

    ssh-copy-id <username>@<host>