Watching a new world…

April 5th, 2007

SCP über ANT mit public rsa key

Normalerweise ist bei einigermaßen sicheren SSH-Servern die Passwortauthentifizierung deaktiviert.

Nun möchte man aber dennoch gerne Automatisches Deployment auf diese Server mittels SCP-Task über ANT realisieren.

Dies ist möglich über RSA-Keys. Da ich immer wieder vergesse, was man da nun genau machen muss, hier nun ein Kochrezept:

  1. Per SSH mit dem User, der auch der Deploy-User wird, auf das Zielsystem einloggen
  2. Im Home-Verzeichnis das Verzeichnis .ssh anlegen
    > md .ssh
  3. Den SSH-Keygenerator starten
    > ssh-keygen -t rsa -f ./.ssh/id_rsa
    Generating public/private rsa key pair.
    Enter passphrase (empty for no passphrase):
  4. Ein Passwort (Passphrase) eingeben:
    Enter same passphrase again:
  5. Nochmal:
    Your identification has been saved in ./.ssh/id_rsa.
    Your public key has been saved in ./.ssh/id_rsa.pub.
    The key fingerprint is:
    0a:c2:a5:bc:90:fb:5d:37:2c:95:21:54:6f:0b:86:38 jboss@blablabla
    Nun sind zwei Dateien entstanden:

    ls -la .ssh/
    -rw------- 1 jboss jboss 1743 2007-03-08 11:51 id_rsa
    -rw-r--r-- 1 jboss jboss 398 2007-03-08 11:51 id_rsa.pub

  6. Dem Verzeichnis .ssh die Rechte für others nehmen:
    > chmod 750 .ssh
  7. Die Datei id_rsa wird auf den lokalen Rechner kopiert
  8. Die Datei id_rsa.pub wird umbenannt zu authorized_keys
    > cd .ssh
    > mv id_rsa.pub authorized_keys
  9. So, nun kann der SCP-Task entsprechend gestartet werden:
    <scp
    port="${scp.port}"
    trust="yes"
    remoteTodir="${scp.user}:${scp.pass}@${scp.host}:${scp.dir}"
    verbose="yes"
    passphrase="${scp.pass}"
    keyfile="${scp.keyfile}">
    <fileset dir="jboss" includes="**/*" />
    </scp>
    …wobei ${scp.keyfile} der Pfad zu der lokalen Datei id_rsa und ${scp.pass} die eingegebene Passphrase ist.

Alles gut!

One Response to “SCP über ANT mit public rsa key”

TheSmile said:

Hi,
kann es sein, dass der SCP-Task Probleme mit großen Keys hat? Ich bekomme es einfach nicht zum Laufen. Die Fehlermeldung ist: invalid privatekey. Mein Key hat die Größe von 4096.

June 11th, 2007 at 10:15

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

klipal online pharmacy buy online cialis viagra online xanax cream for women order zyban online oxazepam buy alternative erection lorazepam cheap drugs 2003 tramadol tramadol market sales tramadol rx pills diazepam discount retail alternative to valium at gnc online drugstore tenuate order order levitra discount cialis buy the cheapest propecia online cheapest generic viagra online drugstore order cialis soft tabs over internet need no doctor cheapest levitra prices woman viagra soft tabs natural substitutes for viagra soft tabs online viagra natural levitra substitutes female cialis alternative