Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
sftp opens a session with a prompt sftp>. You browse the remote folders, download with get and upload with put. It uses the SSH login and encryption, so no extra server is needed: the SSH server has an SFTP subsystem.
Commands with an l in front work on your local side: lls, lcd, lpwd.
Zo schrijf je het
sftp [OPTIONS] [USER@]HOST[:PATH]
sftp [OPTIONS] -b BATCHFILE [USER@]HOSTBelangrijkste delen
Commands at the sftp> prompt
ls[path]/lls[path]- List remote / local files.
cdpath/lcdpath- Change the remote / local folder.
pwd/lpwd- Show the remote / local folder.
getremote[local]- Download a file.
get -rdownloads a folder. putlocal[remote]- Upload a file.
put -ruploads a folder. mgetpattern/mputpattern- Download / upload many files (wildcards).
reget/reput- Continue an interrupted download / upload.
mkdirpath/rmdirpath- Make / remove a remote folder.
rmfile- Remove a remote file.
renameoldnew- Rename a remote file.
chmodmodefile/chownuidfile/chgrpgidfile- Change remote permissions or owner.
ln-stargetlink- Make a remote link.
df[-h]- Show free space on the remote side.
!command- Run a local shell command.
help/?- Show the commands.
bye/exit/quit- Leave sftp.
Opties 24
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Open a session
sftp student@server2 sftp> ls sftp> get /etc/os-release sftp> byegetdownloads to your current local folder.2Upload a file
sftp student@server2 sftp> cd /tmp sftp> put report.pdfThe file goes into the remote folder you are in.
3Change the local folder first
sftp student@server2 sftp> lcd ~/Downloads sftp> get backup.tar.gzlcd= local cd.4Download a whole folder
sftp -r student@server2:/var/www/html ./site-copy-rwith a path downloads recursively without a prompt.5Use another port
sftp -P 2222 admin@files.example.comCapital P, like scp.
6Run commands from a batch file (automation)
cat upload.batch cd /incoming put daily-report.csv bye sftp -b upload.batch partner@sftp.partner.comTypical for sending files to a partner company every night.
7Resume a big download
sftp -a student@server2:/srv/iso/rhel-10.iso .Continues where the last try stopped.
8Check the free space on the server
sftp student@server2 sftp> df -hBefore you upload a big file.
9Upload many files at once
sftp student@server2 sftp> mput *.csvWildcards work on your local file names.
10Use a jump host
sftp -J admin@bastion.example.com admin@10.10.0.20Reach a file server in a private network.
11Run a local command without leaving
sftp student@server2 sftp> !ls -lh!runs the command on your computer.
Niets past bij dit filter.
Let op
- A server can allow SFTP only (chroot), so
sshlogin does not work butsftpdoes — that is on purpose. putandgetoverwrite files with the same name without asking.
Tips om te onthouden
- get = download, put = upload, l = local (lcd, lls, lpwd), bye = leave.