SCP ohne Passwortabfrage

mwiese at beit.de mwiese at beit.de
Wed May 24 09:33:49 CEST 2006


Jan-Benedict Glaw <jbglaw at lug-owl.de> schrieb am 23.05.2006 15:01:05:

> HP -> Linux, Linux -> HP, oder gar beide Richtungen?

HP -> Linux
Allerdings habe ich nun ein Script gefunden, was funktioniert und mir die 
Schlüsselgenerierung und -eintragung abnimmt. Hier ist es:

----schnipp----
#/bin/sh
# This script generates an ssl key for the local machine,
# and copies this key to the remote server.
# This allows a specific user to be granted a passwordless login
# from a specific client machine.
# 2003 Arthur Ketcham

# RSA keys may be subject to export restrictions

if [ ! -n "$1" ]
then
echo "Usage: `basename $0` user at server.com"
exit
fi

if [ ! -e ~/.ssh/id_rsa.pub ]
then
echo "Generating RSA key"
ssh-keygen -t rsa
fi

echo "Copying local SSH pub_key to $1"
echo "Please enter password for remote account:"

# Use scp to opy key to remote temp file

scp ~/.ssh/id_rsa.pub $1:~/.ssh/authorized_keys.tmp

# Append key to ~/.ssh/authorized_keys

echo "Please enter password again to append key to remote 
'authorized_keys' file"
ssh $1 "cat ~/.ssh/authorized_keys.tmp >> ~/.ssh/authorized_keys; rm 
~/.ssh/authorized_keys.tmp; exit"
----schnapp----

Funktioniert einwandfrei. Vielleicht hilfts ja jemandem. Der Dateitransfer 
per SCP von Unix auf Linux läuft nun ohne Eingabe von Passwörtern.

Gruß
Marco



More information about the Linux mailing list