webForumDet fria alternativet

Flytta filer automatiskt?

Linux & BSD

2 svar · 440 visningar · startad av flaerp

Medlem sedan aug. 200030 inlägg
Frågan#1

Skall flytta en fil från server1 till server2 på regelbunden basis mha cron.

Men hur? scp avkräver juh mig ett lösenord.

Datorerna står i olika nät.

Medlem sedan feb. 20001 050 inlägg
#2

Läs i ssh manualen (man ssh), så står det hur du slipper ange lösen då du använder rcp.

Tex:

First, if the machine the user logs in from is listed in /etc/hosts.equiv or /etc/shosts.equiv on the remote machine, and the user names are the same on both sides, the user is immediately permitted to log in. Second, if .rhosts or .shosts exists in the user's home directory on the remote machine and contains a line containing the name of the client machine and the name of the user on that machine, the user is permitted to log in.This form of authentication alone is normally not allowed by the server because it is not secure.

/nicclas - http://www.nic-sys.se

[Redigerat av nicclas den 09 aug 2000]

Medlem sedan dec. 19992 555 inlägg
#3

Observera dock slutet:

... because it is not secure.

Skulle själv skapa en RCA-nyckel utan lösenfras och använda scp med den. Inte heller den lösningen är helt säker, men den är så säker en lösenordfri inloggning kan bli. Och den är definitivt säkrare än rcp-lösningen.

Exempel:

ssh-keygen -b 1024 -f ~/.ssh/hostkey

[Tryck bara <enter> när det frågas efter "passphrase"]

scp ~/.ssh/hostkey.pub username@remotecomputername:~/.ssh/hostkey.pub

ssh -l username -C -x remotecomputername

remotecomputername:~$ cd ~/.ssh

remotecomputername:~/.ssh$ cat ./hostkey.pub >>authorized_keys

remotecomputername:~/.ssh$ rm ./hostkey.pub

remotecomputername:~/.ssh$ exit

Nu skall det gå att använda scp utan att behöva ange lösenord:

scp -i ~/.ssh/hostkey localfilename username@remotecomputername:remotefilename

Var bara rädd om den privata nyckeln ~/.ssh/hostkey. Eftersom den inte är skyddad med en lösenfras så fungerar den som en nyckel till fjärrdatorn. Om någon får tag på den kan de använda den för att logga in.

------------------
Robban < robban@lipogram.com >

276 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
139 ms — deklarationer (db)
0 ms — hämta statistik (cache)
132 ms — hämta tråd, inlägg och bilagor (db)
141 ms — ändringar (db)