Automatische SCP Kopie au einen anderen Server via cron
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Automatische SCP Kopie au einen anderen Server via cron
Hallo,
wie ich mit SCP eine Datei auf einen anderen Server kopiere ist klar. Ich würde das jedoch gerne in einem Cronjob speichern und da gestaltet es sich problematisch weil ja das Kennwort beim Anmelden am anderen Server abgefragt wird.
Und das mit angabe der Keydatei hab ich nicht ganz verstanden.
Hat jemand einen Tip? Hab schon "überall" gesucht
Gruss Dirk
wie ich mit SCP eine Datei auf einen anderen Server kopiere ist klar. Ich würde das jedoch gerne in einem Cronjob speichern und da gestaltet es sich problematisch weil ja das Kennwort beim Anmelden am anderen Server abgefragt wird.
Und das mit angabe der Keydatei hab ich nicht ganz verstanden.
Hat jemand einen Tip? Hab schon "überall" gesucht
Gruss Dirk
-
- Userprojekt
- Posts: 7066
- Joined: 2002-10-09 14:30
- Location: Dorsten
- Contact:
Re: Automatische SCP Kopie au einen anderen Server via cron
Ã?berall ? Dann hast du das offensichtliche wohl überlesen ... ;) :Hat jemand einen Tip? Hab schon "überall" gesucht
http://www.rootforum.org/faq/index.php? ... d=38&lang=
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
Nein wohl doch nicht überall, Danke für den Tipp werde es gleich mal ausprobieren :-DCaptainCrunch wrote:Ã?berall ? Dann hast du das offensichtliche wohl überlesen ... ;) :Hat jemand einen Tip? Hab schon "überall" gesucht
http://www.rootforum.org/faq/index.php? ... d=38&lang=
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
scp Kopie Syntax Fehler ??
Also: ich hab die keys wie beschrieben angelegt, obwohl mir noch nicht so ganz klar geworden ist wohl auf dem Zielserver der *.pub Key hinsoll. Hab den mal in /root/ geschoben.
Nun will ich vom "Quellserver" eine Datei auf den "Zielserver" mit scp kopieren:
was ist da falsch ??
Gruss Dirk
Nun will ich vom "Quellserver" eine Datei auf den "Zielserver" mit scp kopieren:
Code: Select all
scp -i $HOME/.ssh/id_rsa /tmp/backup_log root@xyz.de:
root@xyz.de's password:
Gruss Dirk
Re: Automatische SCP Kopie au einen anderen Server via cron
Fehler 1.obwohl mir noch nicht so ganz klar geworden ist wohl auf dem Zielserver der *.pub Key hinsoll. Hab den mal in /root/ geschoben.
Ich zitiere aus dem genannten Link:
Was bitte ist daran unklar?!4. Jetzt fügst du den Public-Key der Liste von autorisierten Keys hinzu, und zwar mit "cat id_rsa.pub >> ~/.ssh/authorized_keys" bzw. "cat id_dsa.pub >> ~/.ssh/authorized_keys".
Wenn etwas nich tut, wie es soll, sollte man den Client mit -v -vv oder gar -vvv starten, um mehr Infos zu bekommen. Auf dem Server muss natürlich in der /etc/ssh/sshd_config (oder wo auch immer die dort liegt) PubKeyAuthentication Yes oder sowas in der Art drinstehen (gegebenenfalls genaue Syntax nachschlagen).was ist da falsch ??
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
Sorry Ich raffe jetzt überhaupt nichts mehr - Blackout
hab den Befehl :
scp -vvv $HOME/.ssh/id_rsa.pub /tmp/backup_log root@xyz.de:
Auf dem Zielserver hab ich folgende dateien in /etc/ssh
und in der ssh_config
Ich hab die Pub Datei da hinkopiert, aber der SCP Aufruf ist mir vom Syntax her auch noch nicht klar. Hab ich den wie weiter oben beschrieben richtig??
Danke für Deine Geduld !
hab den Befehl :
scp -vvv $HOME/.ssh/id_rsa.pub /tmp/backup_log root@xyz.de:
Code: Select all
p12345678:~ # scp -vvv $HOME/.ssh/id_rsa.pub /tmp/backup_log root@xyz.de:
Executing: program /usr/bin/ssh host xyz.de, user root, command scp -v -d -t .
OpenSSH_3.4p1, SSH protocols 1.5/2.0, OpenSSL 0x0090607f
21009: debug1: Reading configuration data /etc/ssh/ssh_config
21009: debug1: Applying options for *
21009: debug1: Rhosts Authentication disabled, originating port will not be trusted.
21009: debug1: ssh_connect: needpriv 0
21009: debug1: Connecting to xyz.de [217.160.xxx.x] port 22.
21009: debug1: Connection established.
21009: debug1: identity file /root/.ssh/identity type -1
21009: debug3: Not a RSA1 key file /root/.ssh/id_rsa.
21009: debug2: key_type_from_name: unknown key type '-----BEGIN'
21009: debug3: key_read: no key found
21009: debug2: key_type_from_name: unknown key type 'Proc-Type:'
21009: debug3: key_read: no key found
21009: debug2: key_type_from_name: unknown key type 'DEK-Info:'
21009: debug3: key_read: no key found
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug3: key_read: no space
21009: debug2: key_type_from_name: unknown key type '-----END'
21009: debug3: key_read: no key found
21009: debug1: identity file /root/.ssh/id_rsa type 1
21009: debug1: identity file /root/.ssh/id_dsa type -1
21009: debug1: Remote protocol version 1.99, remote software version OpenSSH_3.4p1
21009: debug1: match: OpenSSH_3.4p1 pat OpenSSH*
21009: debug1: Local version string SSH-1.5-OpenSSH_3.4p1
21009: debug1: Waiting for server public key.
21009: debug1: Received server public key (768 bits) and host key (1024 bits).
21009: debug3: check_host_in_hostfile: filename /root/.ssh/known_hosts
21009: debug3: check_host_in_hostfile: match line 2
21009: debug3: check_host_in_hostfile: filename /root/.ssh/known_hosts
21009: debug3: check_host_in_hostfile: match line 2
21009: debug1: Host 'xyz.de' is known and matches the RSA1 host key.
21009: debug1: Found key in /root/.ssh/known_hosts:2
21009: debug1: Encryption type: 3des
21009: debug1: Sent encrypted session key.
21009: debug1: cipher_init: set keylen (16 -> 32)
21009: debug1: cipher_init: set keylen (16 -> 32)
21009: debug1: Installing crc compensation attack detector.
21009: debug1: Received encrypted confirmation.
21009: debug1: Doing password authentication.
Code: Select all
-rw------- 1 root root 88039 Nov 8 2002 moduli
-rw-r--r-- 1 root root 1041 May 12 22:30 ssh_config
-rw------- 1 root root 668 Apr 11 13:42 ssh_host_dsa_key
-rw-r--r-- 1 root root 604 Apr 11 13:42 ssh_host_dsa_key.pub
-rw------- 1 root root 529 Apr 11 13:42 ssh_host_key
-rw-r--r-- 1 root root 333 Apr 11 13:42 ssh_host_key.pub
-rw------- 1 root root 883 Apr 11 13:42 ssh_host_rsa_key
-rw-r--r-- 1 root root 224 Apr 11 13:42 ssh_host_rsa_key.pub
-rw-r--r-- 1 root root 2149 Apr 15 20:39 sshd_config
Code: Select all
Host *
# ForwardAgent no
# ForwardX11 no
# RhostsAuthentication no
RhostsRSAAuthentication yes
RSAAuthentication yes
# PasswordAuthentication yes
# FallBackToRsh no
# UseRsh no
# BatchMode no
# CheckHostIP yes
# StrictHostKeyChecking yes
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_dsa
IdentityFile ~/.ssh/id_rsa
Port 22
Protocol 1,2
# Cipher blowfish
# EscapeChar ~
Danke für Deine Geduld !
Re: Automatische SCP Kopie au einen anderen Server via cron
Meine Herrn, gleich ist meine Geduld echt am Ende, aber ich bemühe mich... :)
Also:
Auf dem Server benötigst du in /etc/ssh/sshd_config folgende Zeilen (u.a.):
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
Das was bei dir unter AuthorizedKeysFile steht bzw. was halt dein Defaultwert dafür ist (siehe manpage!), dahin musst du deinen PupKey kopieren.
Also vom Client aus (erstmal noch mit Passworteingabe):
scp /root/.ssh/id_rsa.pub root@xyz.de:/root/
Dann nochmals ganz normal dort einloggen und auf dem Server folgendes ausführen:
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
(oder wie auch immer das obige File bei dir hieß...)
Und jetzt heißt der Aufruf auf dem Client einfach nur
ssh root@xyz.de
und sollte ohne Passwort gehen, wenn du alles richtig gemacht hast. Wenn nicht, wieder die -vvv dazufügen.
BTW: Man sollte sich nicht also root einloggen ("PermitRootLogin no") und man sollte SSH Protokoll 2 deaktivieren ("Protocols 2"), der Sicherheit wegen!!!
Also:
Auf dem Server benötigst du in /etc/ssh/sshd_config folgende Zeilen (u.a.):
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
Das was bei dir unter AuthorizedKeysFile steht bzw. was halt dein Defaultwert dafür ist (siehe manpage!), dahin musst du deinen PupKey kopieren.
Also vom Client aus (erstmal noch mit Passworteingabe):
scp /root/.ssh/id_rsa.pub root@xyz.de:/root/
Dann nochmals ganz normal dort einloggen und auf dem Server folgendes ausführen:
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
(oder wie auch immer das obige File bei dir hieß...)
Und jetzt heißt der Aufruf auf dem Client einfach nur
ssh root@xyz.de
und sollte ohne Passwort gehen, wenn du alles richtig gemacht hast. Wenn nicht, wieder die -vvv dazufügen.
BTW: Man sollte sich nicht also root einloggen ("PermitRootLogin no") und man sollte SSH Protokoll 2 deaktivieren ("Protocols 2"), der Sicherheit wegen!!!
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
Also - ich hab wie beschrieben folgende Einträge gemacht
AuthorizedKeysFile %h/.ssh/authorized_keys
(der Eintrag war vorher mit #??)
scp /root/.ssh/id_rsa.pub root@xyz.de:/root/.ssh
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
alles weitere genau nach Anleitung Trotzdem:
Was ich nicht begreife: Der Key in der Anleitung wird eine Authenrifizerung nach SSH v.2 gemacht, aber genau das soll ich deaktivieren ??
AuthorizedKeysFile %h/.ssh/authorized_keys
(der Eintrag war vorher mit #??)
scp /root/.ssh/id_rsa.pub root@xyz.de:/root/.ssh
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
alles weitere genau nach Anleitung Trotzdem:
Code: Select all
p15125184:~ # ssh -vvv xyz.de
OpenSSH_3.4p1, SSH protocols 1.5/2.0, OpenSSL 0x0090607f
25846: debug1: Reading configuration data /etc/ssh/ssh_config
25846: debug1: Applying options for *
25846: debug1: Rhosts Authentication disabled, originating port will not be trusted.
25846: debug1: ssh_connect: needpriv 0
25846: debug1: Connecting to xyz.de [217.160.xxx.xx] port 22.
25846: debug1: Connection established.
25846: debug1: identity file /root/.ssh/identity type -1
25846: debug3: Not a RSA1 key file /root/.ssh/id_rsa.
25846: debug2: key_type_from_name: unknown key type '-----BEGIN'
25846: debug3: key_read: no key found
25846: debug2: key_type_from_name: unknown key type 'Proc-Type:'
25846: debug3: key_read: no key found
25846: debug2: key_type_from_name: unknown key type 'DEK-Info:'
25846: debug3: key_read: no key found
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug3: key_read: no space
25846: debug2: key_type_from_name: unknown key type '-----END'
25846: debug3: key_read: no key found
25846: debug1: identity file /root/.ssh/id_rsa type 1
25846: debug1: identity file /root/.ssh/id_dsa type -1
25846: debug1: Remote protocol version 1.99, remote software version OpenSSH_3.4p1
25846: debug1: match: OpenSSH_3.4p1 pat OpenSSH*
25846: debug1: Local version string SSH-1.5-OpenSSH_3.4p1
25846: debug1: Waiting for server public key.
25846: debug1: Received server public key (768 bits) and host key (1024 bits).
25846: debug3: check_host_in_hostfile: filename /root/.ssh/known_hosts
25846: debug3: check_host_in_hostfile: match line 2
25846: debug3: check_host_in_hostfile: filename /root/.ssh/known_hosts
25846: debug3: check_host_in_hostfile: match line 2
25846: debug1: Host 'xyz.de' is known and matches the RSA1 host key.
25846: debug1: Found key in /root/.ssh/known_hosts:2
25846: debug1: Encryption type: 3des
25846: debug1: Sent encrypted session key.
25846: debug1: cipher_init: set keylen (16 -> 32)
25846: debug1: cipher_init: set keylen (16 -> 32)
25846: debug1: Installing crc compensation attack detector.
25846: debug1: Received encrypted confirmation.
25846: debug1: Doing password authentication.
root@xyz.de's password:
BTW: Man sollte sich nicht also root einloggen ("PermitRootLogin no") und man sollte SSH Protokoll 2 deaktivieren ("Protocols 2"), der Sicherheit wegen!!!
Re: Automatische SCP Kopie au einen anderen Server via cron
Irgendwas ist da faul. Vermutlich hast du den Schlüssel falsch erzeugt. Erzeuge das Schlüsselpaar nochmal neu.25846: debug3: Not a RSA1 key file /root/.ssh/id_rsa.
Ups, sorry, das war ein Verschreiber: Protokoll 1 sollte man deaktivieren, 2 ist sicherer.Was ich nicht begreife: Der Key in der Anleitung wird eine Authenrifizerung nach SSH v.2 gemacht, aber genau das soll ich deaktivieren ??
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
neuen Key erzeugt aber ....
keine chance *rsa und auch *dsa schlüssel bringen das gleiche ergebniss wie oben beschrieben. :(
-
- Userprojekt
- Posts: 7066
- Joined: 2002-10-09 14:30
- Location: Dorsten
- Contact:
Re: Automatische SCP Kopie au einen anderen Server via cron
Poste mal einen Link auf deine sshd_config
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
Also sorry wie ich einen Link poste, keine Ahnung. Und da die Suchfunktion mal wieder in diesem forum nicht funzt kann ich auch nicht danach suchen. So gross ist die Datei aber nicht:
Code: Select all
# $OpenBSD: sshd_config,v 1.42 2001/09/20 20:57:51 mouring Exp $
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# This is the sshd server system-wide configuration file. See sshd(8)
# for more information.
Port 22
Protocol 1,2
#ListenAddress 0.0.0.0
#ListenAddress ::
# HostKey for protocol version 1
HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
#obsoletes QuietMode and FascistLogging
# Authentication:
LoginGraceTime 600
PermitRootLogin yes
#PermitRootLogin without-password
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
# rhosts authentication should not be used
RhostsAuthentication no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
PermitEmptyPasswords no
# Uncomment to disable s/key passwords
ChallengeResponseAuthentication no
# Uncomment to enable PAM keyboard-interactive authentication
# Warning: enabling this may bypass the setting of 'PasswordAuthentication'
#PAMAuthenticationViaKbdInt yes
# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no
# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes
X11Forwarding no
X11DisplayOffset 10
PrintMotd yes
#PrintLastLog no
KeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
#ReverseMappingCheck yes
Subsystem sftp /usr/lib/ssh/sftp-server
IgnoreUserKnownHosts no
ReverseMappingCheck no
GatewayPorts no
AllowTcpForwarding yes
UsePrivilegeSeparation yes
-
- Posts: 531
- Joined: 2003-01-09 08:58
- Location: NRW
Re: Automatische SCP Kopie au einen anderen Server via cron
und klappt es mittlerweile ?
Dirk
Dirk
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
ne leider immer och das selbe Problem. Hast Du evt einen Tipp ??
Gruss
Gruss
-
- Posts: 531
- Joined: 2003-01-09 08:58
- Location: NRW
Re: Automatische SCP Kopie au einen anderen Server via cron
nee haeb wogl genau das gleiche Problem.
Dirk
Dirk
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
Wie es ausschaut hat das Forum hier auch keinen Tipp mehr ??? 
Re: Automatische SCP Kopie au einen anderen Server via cron
inProtocol 1,2
ändern und dann den sshd neu startenProtocol 2
ssh -v -i identitiy.file user@host gibt einen Fehler mit, dne ihr posten könntet.
Re: Automatische SCP Kopie au einen anderen Server via cron
oder jemand ein login geben
Karlo
Karlo
-
- Posts: 39
- Joined: 2003-04-04 19:57
- Location: Göttingen
Re: Automatische SCP Kopie au einen anderen Server via cron
Hatte noch einen kleinen Syntax Fehler drinn aber nun funzt es !! :-D :-D Wenn ich das jetzt auch noch "PUTTY" bei´bringe (was noch nicht klappt, da es den id_rsa nicht mag) dann bin ich überglücklich
Viele Dank nochmal Gruss Dirk
Viele Dank nochmal Gruss Dirk