Basic commands for SFTP file transfer - Musa - Blog Park (cnblogs.com)
1.sftp to establish a connection
[root@localhost ~]# sftp username@remote_ip(or remote host name), # connect root user, you can omit "root@".
[root@localhost ~]# sftp -o port=1000 username @remote_ip
[root@localhost ~]# sftp [email protected]
2. sftp - Upload files: If the upload/download is a folder, just add the -r parameter after the put/get command.
Upload file: Upload the study.log file under the /www/wwwroot directory of the local server to the /www/server directory of the remote server.
sftp> lcd /www/wwwroot
sftp> put study.log /www/server
upload folder: upload the test folder under the /www/wwwroot directory of the local server to the /www/server directory of the remote server.
sftp> put -r test /www/server
View files and folders under the remote server /www/server directory
sftp> ls /www/server
3. sftp - download files
Download file: Download the study.log file under the /www/server directory of the remote server to the /www directory of the local server.
sftp> get /www/server/study.log /www
download folder: download the test folder under the /www/server directory of the remote server to the /www directory of the local server.
sftp> get -r /www/server/test /www
View files and folders under the local server /www directory
sftp> lls /www
4. sftp has almost the same syntax and functions as ftp
① ls, rm, cd, mkdir, pwd and other commands are operations on the currently connected remote server.
② lls, lrm, lcd, lmkdir, lpwd and other commands are operations on the local server - just add l (local) before the above commands
5. exit sftp
exit