ssh-copy-id (207311) | ssh-copy-id (214979) |
---|---|
1#!/bin/sh 2 3# Shell script to install your public key on a remote machine 4# Takes the remote machine name as an argument. 5# Obviously, the remote machine must accept password authentication, 6# or one of the other keys in your ssh-agent, for this to work. 7 8ID_FILE="${HOME}/.ssh/id_rsa.pub" --- 24 unchanged lines hidden (view full) --- 33 exit 1 34fi 35 36if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then 37 echo "Usage: $0 [-i [identity_file]] [user@]machine" >&2 38 exit 1 39fi 40 | 1#!/bin/sh 2 3# Shell script to install your public key on a remote machine 4# Takes the remote machine name as an argument. 5# Obviously, the remote machine must accept password authentication, 6# or one of the other keys in your ssh-agent, for this to work. 7 8ID_FILE="${HOME}/.ssh/id_rsa.pub" --- 24 unchanged lines hidden (view full) --- 33 exit 1 34fi 35 36if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then 37 echo "Usage: $0 [-i [identity_file]] [user@]machine" >&2 38 exit 1 39fi 40 |
41{ eval "$GET_ID" ; } | ssh $1 "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1 | 41# strip any trailing colon 42host=`echo $1 | sed 's/:$//'` |
42 | 43 |
44{ eval "$GET_ID" ; } | ssh $host "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys" || exit 1 45 |
|
43cat <<EOF | 46cat <<EOF |
44Now try logging into the machine, with "ssh '$1'", and check in: | 47Now try logging into the machine, with "ssh '$host'", and check in: |
45 | 48 |
46 .ssh/authorized_keys | 49 ~/.ssh/authorized_keys |
47 48to make sure we haven't added extra keys that you weren't expecting. 49 50EOF | 50 51to make sure we haven't added extra keys that you weren't expecting. 52 53EOF |
54 |
|