SFTP直接可以使用SSH账户登录:
sftp user@romoteIP
sftp -oPort=custom_port ser@romoteIP
查看帮助:
help
内容如下:
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 [-afPpRr] remote [local] Download file
reget [-fPpRr] remote [local] Resume download file
reput [-fPpRr] [local] remote Resume upload 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 [-afPpRr] 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
查看远程当前目录:
pwd
查看本地当前目录:
lpwd
查看远程当前目录文件:
ls
查看本地当前目录文件:
lls
切换远程目录:
cd
切换本地目录:
lcd
语法:
get remoteFile.txt
重命名下载的文件:
get remoteFile.txt localFile.txt
下载文件夹到本地:
get -r someDirectory
下载文件夹到本地且保持文件夹权限属性:
get -Pr someDirectory
语法:
put localFile.txt
其他语法和下载 get 基本相同。
查看远程服务器可用容量:
df -h
以上命令无法直接查看本地容量,可用 ! 来实现:
!
df -h
使用 ! 后任何本地命令都可以使用了,要想切换回 sftp 模式,使用如下命令:
exit
以上就是常用的 SFTP 用法。