SCP ohne Passwortabfrage

Jan-Benedict Glaw jbglaw at lug-owl.de
Wed May 24 10:22:24 CEST 2006


On Wed, 2006-05-24 09:33:49 +0200, mwiese at beit.de <mwiese at beit.de> wrote:
> 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

Nur ein key pro user? Kein Kommentar?

> 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

Nette race condition.

> # 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"

Das geht in die Hose, wenn auf dem fremden Rechner das
~/.ssh/-Verzeichnis noch nicht existiert.
> ----schnapp----
> 
> Funktioniert einwandfrei. Vielleicht hilfts ja jemandem. Der Dateitransfer 
> per SCP von Unix auf Linux läuft nun ohne Eingabe von Passwörtern.

Was zu erwarten war:-)  Aber jetzt solltest Du auch per Hand keys
erzeugen und weiterkopieren können.

MfG, JBG

-- 
Jan-Benedict Glaw       jbglaw at lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lug-owl.de/pipermail/linux/attachments/20060524/4fc86411/attachment.sig>


More information about the Linux mailing list