Set up passwordless file exchanges
You can send and retrieve files using public/private key pair authentication for passwordless SFTP. This automates delivery of files to OCLC and eliminates the need to manually enter a password when using an OCLC file exchange account. It also allows your institution to change the key on a regular basis for added security.
Per motivi di sicurezza, OCLC non supporta il passaggio della password SFTP tramite uno script, ma offre invece la soluzione di coppia di chiavi pubblica/privata per consentire la scrittura di script completamente automatici da caricare e scaricare sul nostro server.
Nota: OCLC supporta SHA-224 e versioni successive.
Linux
Questa procedura è per sistemi Linux. Sebbene metodi simili vengano utilizzati per altri sistemi, OCLC ha testato questo metodo utilizzando Linux come computer client SCP e SFTP. Viene richiesta una password durante il caricamento della chiave pubblica, ma una volta sostituita, gli accessi futuri e i trasferimenti di file non richiedono una password.
Generate and upload your public key
To generate and upload your public key to your OCLC file exchange account:
- Generate a private/public key pair on your client machine and put it in a file called /home/user1/.SSH/id_rsa.pub on your local machine.
If you are unsure how to generate a private/public key pair, you can use the method described below, which puts the private/public key file in the correct place on your local machine automatically. - Carica la tua chiave pubblica su .ssh/authorized_keys nel tuo account di scambio file OCLC.
non eliminare il file esistente .ssh/authorized_keys file prima di caricare quello nuovo. Il nuovo file caricato sostituisce automaticamente il file esistente pur mantenendo le autorizzazioni e le proprietà di proprietà. Se si elimina il file esistente prima di caricare il nuovo file, i diritti sul sistema non saranno sufficienti per impostare la proprietà del gruppo necessaria per .ssh/authorized_keys e pertanto continuerà a essere chiesta una password.
Automatizza un trasferimento SFTP tra due server
SSH configuration
Most of this relies on configuration of SSHd, the SSH (Secure SHell) daemon running on the server you’re attempting to connect to. This server will be referred to as "server2.com" for demonstration purposes.
Controllare "SSHd_config" su quel server, in genere in /etc/SSH. In alcuni casi, queste impostazioni non sono sempre presenti o impostate come è necessario:
RSAAuthentication sì PubkeyAuthentication sì
This enables the public/private key authentication mechanism you will use.
Public/Private key generation
Generare la coppia di chiavi sulla macchina Linux da cui ci si vuole connettere. Questo server sarà denominato "server1.com" a scopo dimostrativo. È quella casella che si prevede di eseguire SSH, SFTP o Rsync.
SSH-keygen -t rsa Generazione coppia di chiavi RSa pubblica/privata. Immettere il file in cui salvare la chiave (/home/user1/.SSH/id_rsa): Immettere passphrase (vuoto per nessuna passphrase): Immettere nuovamente la stessa passphrase: L'identificazione è stata salvata in .SSH/id_rsa. La chiave pubblica è stata salvata in .SSH/id_rsa.pub. L'impronta della chiave è: c1:21:e 3:01:26:0d:f7:ec:52:0e:0c:90:9b:6e:d8:47 user1@server1.com
The command above generates a public/private key pair. Respond to each prompt by pressing <Enter>. Possession of the private key is sufficient to gain access to what ever resources into which you’ve placed the corresponding public key.
You must not enter a passphrase for the private key to configure an automated solution. If you do enter a passphrase, you'll need to enter it to use the private key.
Note: By not placing a passphrase on your private key, the security implication is that mere possession of the private key is sufficient to gain access to whatever resources into which you’ve placed the corresponding public key. Safeguard your private key.
La chiave privata è stata inserita in /home/user1/.SSH/id_rsa. Questo deve essere protetto a causa delle implicazioni di sicurezza di cui sopra, ma deve anche essere disponibile per il processo di tentativo di effettuare una connessione SSH, SFTP o Rsync. Se questi strumenti vengono eseguiti con l'account 'utente1', gli strumenti cercheranno automaticamente nella directory ".SSH" e non sarà necessario specificare la posizione della chiave privata. In caso contrario, le opzioni della riga di comando devono puntare alla posizione e alla chiave corrette.
The public key is in /home/user1/.SSH/id_rsa.pub. This is the key that gets distributed to those places that want to grant you access.
Inserire la chiave pubblica
- On the remote server, server2.com, pick any account that you want to connect to.
- In that account’s home directory, create a .ssh subdirectory and create a new text file named authorized_keys in that directory. If a text file by this name already exists, use the existing file.
- On the remote server, server2.com, pick any account that you want to connect to. In that account’s home directory, create a .ssh subdirectory and create a new text file named authorized_keys in that directory. If a text file by this name already exists, use the existing file.
Nota: se si crea il file e/o la directory, si consiglia che la directory sia chmod 700 e il file 600. In questo modo, solo il proprietario può accedere alla directory e al file in essa contenuto.
- Add to that file the contents of the id_rsa.pub file created above. That would be a *single line* that looks something like this:
ssh-rsa <lots of characters> utente1@server1.com
- Una volta salvata, chiunque possieda la chiave privata che corrisponde a questa chiave pubblica può ora accedere a questo account.
SFTP
The public key was planted in the account user2 on server2.com. So now, server1.com logged in as user1, and where the private key is stored as described above, an sftp session looks like this:
sftp utente2@server2.com
"user2" specifica l'account remoto su server2.com per accedere come.
L'autenticazione avviene perché la chiave privata corrisponde alla chiave pubblica, il che indica che si è autorizzati ad accedere a tale account. È stata aperta una sessione SFTP senza che sia richiesta alcuna interattività.
Note: If you did enter a passphrase on the private key, you would have been prompted to enter it here. This is the passphrase to unlock the private key, which is local. It has nothing to do with any passwords on the remote site
Rsync
You can use Rsync for file copy operations, which can handle intelligent compression, copy only if needed, recursion, compression attribute retention, date/time stamp, and many other operations.
If all the keys are set up as above, this Rsync command copies a file from the local machine to the remote:
rsync -e ssh file user2@server2.com:/home/user2/
Il file locale "file" viene copiato nel /home/user2/file remoto dopo aver effettuato l'accesso come "utente2" utilizzando ssh come trasporto (da cui l'opzione "-e ssh") e, con quello, utilizzando la coppia di chiavi privata/pubblica creato per l'autenticazione senza interattività richiesta.
SSH
SSH works as well to open up a remote shell once the keys are in place. If all keys are set up as above, this SSH command opens a remote shell on server2, logged in as user2.
ssh utente2@server2.com
Esempio
The examples below indicate more than one space to illustrate where a space is needed. When entering your commands, please use only one space.
If using a Linux-based system, you can use either of these commands to upload the public key file to the correct location. Before using either of these commands, you must generate a private/public key.
| Method | Passaggi |
|---|---|
| SFTP |
|
| Secure Copy |
|
If using an SFTP client such as FileZilla, take the following steps to upload the public key file to the correct location. Before using this command, you must generate a private/public key.
| Method | Passaggi |
|---|---|
| SFTP |
|
