sftp命令详解

您所在的位置:网站首页 停止ssh服务的命令有哪些 sftp命令详解

sftp命令详解

2023-07-12 07:30| 来源: 网络整理| 查看: 265

sftp命令详解 原创

mb649d3a75b51a2 2023-07-02 12:53:02 ©著作权

文章标签 methods file string compression user 文章分类 Python 后端开发

©著作权归作者所有:来自51CTO博客作者mb649d3a75b51a2的原创作品,请联系作者获取转载授权,否则将追究法律责任

Looks like sftp doesn't  distinguish Binary files and ASCII files at all. That means it doesnt support the commands like 'bin' or 'ascii' that ftp supports.

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 [-P] remote-path [local-path] 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 oldpath newpath Symlink remote file lpwd Print local working directory ls [-1aflnrSt] [path] Display remote directory listing lumask umask Set local umask to 'umask' mkdir path Create remote directory progress Toggle display of progress meter put [-P] local-path [remote-path] 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 =================================================== Usage: sftp [options]... [profile|[user@]host[#port]]Access remote files using the Secure Shell protocol. Options: -b buffer_size_bytes Define maximum buffer size for one request (default: 32768 bytes). -B batch_file Use batch file. -D, --debug=LEVEL Set debug level string to LEVEL. -N max_requests Define maximum number of requests sent in parallel (default: 10). -P port Connect to this SSH port on the remote machine (default: 22). -v, --verbose Use verbose mode (equal to `-D 2'). --keep-alive=VALUE Send no-operational packet to the server, each specified amount of time. --tcp-connect-timeout=VALUE Overwrite default timeout value that is used when connecting to a server. -i file Use private keys defined in identification file to authenticate with public key method. --identity=ID Use private key 'id' as user identification. The 'id' can be either key id, key hash or a key file name. --identity-key-id=ID Use key id as a user identification. --identity-key-hash=ID Use key hash as a user identification. -K, --identity-key-file=FILE Use key file as a user identification. --allowed-authentications=METHODS --aa=METHODS Allow only selected methods in user authentication. The 'methods' is a comma separated list of authentication methods. Giving value 'help' lists available methods. --kip Same as '--aa=keyboard-interactive,password'. -c, --ciphers=CIPHERS Allow only selected ciphers to be used. Giving value 'help' lists available ciphers. --macs=MACS Allow only selected MACs to be used. Giving value 'help' lists available MACs. --kexs=KEXS Allow only selected KEX methods to be used. Value 'help' lists available KEX methods. --hostkey-algorithms=HOSTKEYALGORITHMS Allow only selected hostkey algorithms to be used. Value 'help' lists available hostkey algorithms -C Disables compression. +C Enables zlib compression. --compressions=METHODS Allow selected compression methods. Giving value 'help' lists available methods. --exclusive Opens always a new connection, does not share connection. --fips Performs checksums using the FIPS cryptographic library. --password= Set user password. Giving the PASSWORD PASSWORD| directly as the argument is not secure! file://FILE| Give either a path to FILE containing the extprog://PROG password, or a path to external program that will output the password. --plugin-path=PATH Set plugin path to PATH. This is only used in FIPS mode. -V, --version Display program version and exit. -q, --quiet Suppress the printing of error, warning and informational messages. -h, --help Display this help and exit. ========= StringBuffer cmd = new StringBuffer(sftpSSH); String space = " "; cmd.append(space).append("PUT"); cmd.append(space).append(ftpInfo.getFtpUser()); cmd.append(space).append(ftpInfo.getFtpDestination()); cmd.append(space).append(ftpInfo.getFtpPort()); cmd.append(space).append(localDir); cmd.append(space).append(ftpInfo.getFtpFolder()); cmd.append(space).append(fileName); String remoteFileName = ftpInfo.getFtpFileName(); if(ftpInfo.getFtpFileDateFormat()!=null && ftpInfo.getFtpFileType()!=null) { Date d = new Date(); String s = DateFormatUtils.format(d,ftpInfo.getFtpFileDateFormat()); remoteFileName=remoteFileName+s; remoteFileName=remoteFileName+'.'+ftpInfo.getFtpFileType(); } cmd.append(space).append(remoteFileName); logger.info("call sftp shell command:" + cmd.toString()); Process proc = Runtime.getRuntime().exec(cmd.toString());  BufferedReader in = new BufferedReader (new InputStreamReader(proc.getInputStream())); BufferedReader inE = new BufferedReader (new InputStreamReader(proc.getErrorStream())); StringBuffer errMsg = new StringBuffer(); String s = null; errMsg.append("\nSFTP script Stand Output:\n"); while ((s = in.readLine()) != null){ s = s.trim(); errMsg.append(s+"\n"); } errMsg.append("\nSFTP script Err Output:\n"); while((s = inE.readLine()) != null){ if(s.trim().length() > 0){ errMsg.append(s+"\n"); } } return errMsg.toString();===================================== if [ $CMD = "PUT" ]; then logInput $1 $2 $3 $4 $5 $6 $7 $8 checkLocalDir $5 checkFileExist "$5$FILESEP$7" $CMD if [ "$5$FILESEP$7" != "$5$FILESEP$8" ]; then cp "$5$FILESEP$7" "$5$FILESEP$8" fi BATCHFTPFILE=/tmp/sftpUtilBatch echo lcd $5 > $BATCHFTPFILE echo cd $6 >> $BATCHFTPFILE echo put $8 >> $BATCHFTPFILE returnC=`/usr/local/bin/sftp -B $BATCHFTPFILE $2@$3#$4` if [ $? = 1 ]; then echo $returnC >>$LOGFILE echo $returnC exit 1 fi if [ "$5$FILESEP$7" != "$5$FILESEP$8" ]; then rm "$5$FILESEP$8" fi echo $returnC >>$LOGFILE echo $returnC exit 0 fi ==================

sftp -i ~/.ssh2/identification

.ssh2/下包含identification 文件和xxx.key.pub

identification的内容是key xxx.key.pub

xxx.key.pub的内容是密钥

收藏 评论 分享 举报

上一篇:Dos 中实现else if 功能

下一篇:XP中怎样让批处理文件运行后,不关闭dos窗口



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3