Linux的sftp命令教程

sftp常用命令:[url]http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888391.html[/url]
分别在192.168.126.128的家目录下建test.sh文件
在192.168.126.129的家目录下建mark.sh文件

查看192.168.126.128家目录下的文件
[url]Donald_Draper@suse-gcdb:~> ls
crontab.log test.sh [/url]

现在用sftp命令,从192.168.126.128登陆到192.168.126.129
Last login: Sun Oct 30 01:01:36 2016 from 192.168.126.128
命令
sftp user@ip 如果没有user,默认以当前用户ssh登陆
Donald_Draper@suse-gcdb:~> sftp 192.168.126.129 
Password:
Connected to 192.168.126.129.
sftp> pwd
Remote working directory: /home/Donald_Draper
sftp> ll
Invalid command.
sftp> ls -al
drwxr-xr-x 4 Donald_Draper gdm 4096 Oct 29 17:03 .
drwxr-xr-x 7 root root 4096 Sep 22 15:34 ..
drwxr-xr-x 2 Donald_Draper users 4096 Sep 27 09:17 .InstallAnywhere
-rw------- 1 Donald_Draper users 4203 Oct 20 21:39 .bash_history
-rwxrwxrwx 1 Donald_Draper users 8333 Oct 19 10:51 .com.zerog.registry.xml
-rw------- 1 Donald_Draper users 204 Sep 28 11:40 .isql_history
drwx------ 2 Donald_Draper users 4096 Oct 14 14:02 .ssh
-rw------- 1 Donald_Draper users 4652 Oct 29 17:00 .viminfo
-rw-r--r-- 1 Donald_Draper users 271 Sep 22 16:13 bash_profile
-rw-r--r-- 1 Donald_Draper users 0 Oct 29 17:00 mark.sh

从192.168.126.129下载文件到192.168.126.128
命令
get source destination
如果没有destination参数,这下载到当前目录
sftp> get ./mark.sh /home/Donald_Draper
Fetching /home/Donald_Draper/./mark.sh to /home/Donald_Draper/mark.sh



从192.168.126.128上载文件到192.168.126.129
命令
put source destination
如果没有destination参数,则上传到Donald_Draper在192.168.126.129的家目录下

sftp> put /home/Donald_Draper/test.sh /home/Donald_Draper/
Uploading /home/Donald_Draper/test.sh to /home/Donald_Draper/test.sh
/home/Donald_Draper/test.sh 100% 4 0.0KB/s 00:00

查看192.168.126.129家目录下的文件,多了一个test.sh
sftp> ls -al
drwxr-xr-x 4 Donald_Draper gdm 4096 Oct 29 17:03 .
drwxr-xr-x 7 root root 4096 Sep 22 15:34 ..
drwxr-xr-x 2 Donald_Draper users 4096 Sep 27 09:17 .InstallAnywhere
-rw------- 1 Donald_Draper users 4203 Oct 20 21:39 .bash_history
-rwxrwxrwx 1 Donald_Draper users 8333 Oct 19 10:51 .com.zerog.registry.xml
-rw------- 1 Donald_Draper users 204 Sep 28 11:40 .isql_history
drwx------ 2 Donald_Draper users 4096 Oct 14 14:02 .ssh
-rw------- 1 Donald_Draper users 4652 Oct 29 17:00 .viminfo
-rw-r--r-- 1 Donald_Draper users 271 Sep 22 16:13 bash_profile
-rw-r--r-- 1 Donald_Draper users 0 Oct 29 17:00 mark.sh
-rw-r--r-- 1 Donald_Draper users 4 Oct 29 17:03 test.sh

查看192.168.126.128家目录下的文件
sftp> exit
Donald_Draper@suse-gcdb:~> ls
crontab.log test.sh mark.sh

你可能感兴趣的:(Linux)