Files
dotfiles/vim/wiki_html/ssh-copy-id.html
2014-02-05 14:27:09 +01:00

84 lines
2.4 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="./styles/shCore.css" />
<link type="text/css" rel="stylesheet" href="./style.css" />
<link type="text/css" rel="stylesheet" href="./styles/shThemeDefault.css" />
<script type="text/javascript" src="./scripts/shCore.js"></script>
<script type="text/javascript" src="./scripts/shBrushBash.js"></script>
<script type="text/javascript" src="./scripts/shBrushJava.js"></script>
<script type="text/javascript">
SyntaxHighlighter.all();
</script>
</head>
<body>
<h1 id="toc_1">SSH Key kopieren</h1>
<pre class="brush: bash; ; toolbar: false;">
$ cat ~/.ssh/*.pub | ssh user@remote-system 'umask 077; cat &gt;&gt;.ssh/authorized_keys'
</pre>
<p>
oder als shell-Script nutzten
</p>
<pre class="brush: bash; ; toolbar: false;">
#!/bin/sh
# Shell script to install your identity.pub on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/identity.pub"
if [ "-i" = "$1" ]; then
shift
# check if we have 2 parameters left, if so the first is the new ID file
if [ -n "$2" ]; then
if expr "$1" : ".*\.pub" ; then
ID_FILE="$1"
else
ID_FILE="$1.pub"
fi
shift # and this should leave $1 as the target name
fi
else
if [ x$SSH_AUTH_SOCK != x ] ; then
GET_ID="$GET_ID ssh-add -L"
fi
fi
if [ -z "`eval $GET_ID`" ] &amp;&amp; [ -r "${ID_FILE}" ] ; then
GET_ID="cat ${ID_FILE}"
fi
if [ -z "`eval $GET_ID`" ]; then
echo "$0: ERROR: No identities found" &gt;&amp;2
exit 1
fi
if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 [-i [identity_file]] [user@]machine" &gt;&amp;2
exit 1
fi
{ eval "$GET_ID" ; } | ssh $1 "umask 077; test -d .ssh || mkdir .ssh ; cat &gt;&gt; .ssh/authorized_keys" || exit 1
cat &lt;&lt;EOF
Now try logging into the machine, with "ssh '$1'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
EOF
</pre>
<p>
[ <a href="index.html">Go home</a> ]
</p>
</body>
</html>