Linux sftp command tutorial

sftp common commands: http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888391.html
Build the test.sh file
in the home directory of 192.168.126.128 and build it in the home directory of 192.168.126.129 mark.sh file

View the files in the 192.168.126.128 home directory
[url]Donald_Draper@suse-gcdb:~> ls
  crontab.log test.sh [/url]
 
Now use the sftp command to log in from 192.168.126.128 to 192.168.126.129
Last login: Sun Oct 30 01:01:36 2016 from 192.168.126.128
Command
sftp user@ip If there is no user, the default is to log in with the current 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

Download files from 192.168.126.129 to 192.168.126.128
command
get source destination
If there is no destination parameter, this downloads to the current directory
sftp> get ./mark.sh /home/Donald_Draper
Fetching /home/Donald_Draper/./mark.sh to /home/Donald_Draper/mark.sh



Upload a file from 192.168.126.128 to 192.168.126.129
command
put source destination
If there is no destination parameter, upload it to Donald_Draper's home directory in 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  

Check the files in the 192.168.126.129 home directory, there is one more 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

View the files in the 192.168.126.128 home directory
sftp> exit
Donald_Draper@suse-gcdb:~> ls
  crontab.log    test.sh      mark.sh


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326974621&siteId=291194637