L'utilisation de ces commandes est relativement simple. SCP permet de faire de la copie de fichiers. SFTP est utilisable en mode intéractif ou en mode batch et ressemble plus au FTP.
La commande
M0:$ ssh mlx@M1.foo.org "ls -al psionic" -rw-r--r-- 1 root root 64562 Nov 23 23:05 hostsentry-0.02-4.noarch.rpm -rw-r--r-- 1 root root 26955 Nov 23 23:05 logsentry-1.1.1-1.i386.rpm -rw-r--r-- 1 root root 48804 Nov 23 23:06 portsentry-1.1-fr7.i386.rpm -rw-r--r-- 1 root root 48804 Nov 23 23:13 portsentry-1.1-fr7.i386.rpm.1
La commande :
ssh mlx@M1.foo.org "ls -al"
donne la liste des fichiers distants qui sont dans le répertoire "psionic". Pour copier ces fichiers localement dans un répertoire psionic on va utiliser :
cd && mkdir psionic scp mlx@M1.foo.org:/home/mlx/psionic/* ~/psionic
Ou pour envoyer les fichiers du répertoire local psionic, vers le répertoire tmp qui est dans /home/mlx de la machine M1.foo.org :
scp ~/psionic/* mlx@foo.org:/home/mlx/tmp
sftp peut être utilisé pour du transfert de fichiers en mode sécurisé.
sftp mlx@M1.foo.org sftp>
On obtient un prompt, ici le système ne m'a pas demandé de m'authentifier. Pour avoir une liste des commandes, utiliser "help".
sftp> help Available commands: cd path Change remote directory to 'path' lcd path Change local directory to 'path' chgrp grp path Change group of file 'path' to 'grp' chmod mode path Change permissions of file 'path' to 'mode' chown own path Change owner of file 'path' to 'own' help Display this help text get remote-path [local-path]Download file lls [ls-options [path]] Display local directory listing ln oldpath newpath Symlink remote file lmkdir path Create local directory lpwd Print local working directory ls [path] Display remote directory listing lumask umask Set local umask to 'umask' mkdir path Create remote directory put local-path [remote-path]Upload file pwd Display remote working directory exit Quit sftp quit Quit sftp rename oldpath newpath Rename remote file rmdir path Remove remote directory rm path Delete remote file symlink oldpath newpath Symlink remote file version Show SFTP version !command Execute 'command' in local shell ! Escape to local shell ? Synonym for help