Automatische Datentransfers per SFTP mit Passwort und via Proxy: Unterschied zwischen den Versionen

Aus UUGRN
Zur Navigation springen Zur Suche springen
Rabe (Diskussion | Beiträge)
Ein Anfang
 
Rabe (Diskussion | Beiträge)
K sftp-commands
Zeile 19: Zeile 19:


Wir müssen also für alle Zugriffe das "sftp"-Tool verwenden, oder zumindest das "sftp"-Subsystem per ssh ansprechen.
Wir müssen also für alle Zugriffe das "sftp"-Tool verwenden, oder zumindest das "sftp"-Subsystem per ssh ansprechen.
Mittels '''sftp -b''' kann man einfache vordefinierte Batchscripte ausführen, also eine Abfolge von diesen commands:
</pre>
sftp> help
Available commands:
bye                                Quit sftp
cd path                            Change remote 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'
df [-hi] [path]                    Display statistics for current directory or
                                  filesystem containing 'path'
exit                              Quit sftp
get [-Ppr] remote [local]          Download file
help                              Display this help text
lcd path                          Change local directory to 'path'
lls [ls-options [path]]            Display local directory listing
lmkdir path                        Create local directory
ln [-s] oldpath newpath            Link remote file (-s for symlink)
lpwd                              Print local working directory
ls [-1afhlnrSt] [path]            Display remote directory listing
lumask umask                      Set local umask to 'umask'
mkdir path                        Create remote directory
progress                          Toggle display of progress meter
put [-Ppr] local [remote]          Upload file
pwd                                Display remote working directory
quit                              Quit sftp
rename oldpath newpath            Rename remote file
rm path                            Delete remote file
rmdir path                        Remove remote directory
symlink oldpath newpath            Symlink remote file
version                            Show SFTP version
!command                          Execute 'command' in local shell
!                                  Escape to local shell
?                                  Synonym for help
</pre>

Version vom 2. August 2016, 15:36 Uhr

Dieser Artikel beschreibt einen Spezialfall aus dem Bereich OpenSSH, bei dem mehrere erschwerende Bedingungen zusammenkommen:

  • Es sollen automatisiert Dateien per SFTP ausgetauscht werden
  • Zugriff auf den Server ausschließlich mit SFTP möglich, keine normale SSH-Shell, kein scp, kein rsync+ssh oder ähnliches.
  • Zugriff auf das Zielsystem nur per HTTP-Proxy möglich
  • Zugriff auf den Account nur mit Benutzername und Passwort möglich, keine Public-Key Authentifikation möglich
  • Zugriffe sollen gescriptet werden (Batch-Mode, Shell-Scripte), also nicht-interaktiv


Allgemein

Für jede der Bedinungen gibt es einzelne Lösungen, die im Zusammenspiel allerdings trickreich sein können.

nur SFTP

Für viele Anwendungsfälle aus dem Bereich automatisierter Filetransfer greift man zu Lösungen wie scp oder rsync+ssh oder andere Konstrukte die direkt auf ssh aufbauen. In diesem Fall ist auf dem Zielserver nur sftp möglich.

sftp ist ein sogenannte subsystem aus SSH und nur genau dieses Subsystem ist für uns erreichbar.

This service allows sftp connections only.

Wir müssen also für alle Zugriffe das "sftp"-Tool verwenden, oder zumindest das "sftp"-Subsystem per ssh ansprechen.

Mittels sftp -b kann man einfache vordefinierte Batchscripte ausführen, also eine Abfolge von diesen commands:

sftp> help Available commands: bye Quit sftp cd path Change remote 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' df [-hi] [path] Display statistics for current directory or

                                  filesystem containing 'path'

exit Quit sftp get [-Ppr] remote [local] Download file help Display this help text lcd path Change local directory to 'path' lls [ls-options [path]] Display local directory listing lmkdir path Create local directory ln [-s] oldpath newpath Link remote file (-s for symlink) lpwd Print local working directory ls [-1afhlnrSt] [path] Display remote directory listing lumask umask Set local umask to 'umask' mkdir path Create remote directory progress Toggle display of progress meter put [-Ppr] local [remote] Upload file pwd Display remote working directory quit Quit sftp rename oldpath newpath Rename remote file rm path Delete remote file rmdir path Remove remote directory symlink oldpath newpath Symlink remote file version Show SFTP version !command Execute 'command' in local shell ! Escape to local shell ? Synonym for help