Ubuntu 15.04
Sponsored Link

SSH File Transfer (Ubuntu Client)2015/04/24

 
It's possible to transfer files with SSH.
[1] It's the exmaple for using SCP (Secure Copy).
# scp [Option] Source Target

# copy the [test.txt] on local to remote server [www.srv.world]

vervet@dlp:~$
scp ./test.txt vervet@www.srv.world:~/

vervet@10.0.0.30's password:
# password of the user

test.txt                                                100%   10     0.0KB/s   00:00

# copy the [/home/cent/test.txt] on remote server [www.srv.world] to the local

vervet@dlp:~$
scp vervet@www.srv.world:/home/vervet/test.txt ./test.txt

vervet@10.0.0.30's password:
test.txt                                                100%   10     0.0KB/s   00:00
[2] It's example to use SFTP (SSH File Transfer Protocol).
SFTP server function is enabled by default but if not, enable it to add the line [Subsystem sftp /usr/lib/openssh/sftp-server] in [/etc/ssh/sshd_config].
# sftp [Option] [user@host]

ubuntu@dlp:~$
sftp vervet@www.srv.world

vervet@www.srv.world's password:
# password of the user

Connected to www.srv.world.
sftp>
# show current directory on remote server

sftp>
pwd

Remote working directory: /home/vervet
# show current directory on local server

sftp>
!pwd

/home/ubuntu
# show files in current directory on FTP server

sftp>
ls -l

drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:33 public_html
-rw-rw-r--    1 vervet     vervet           10 Jul 28 22:53 test.txt
# show files in current directory on local server

sftp>
!ls -l

total 4
-rw-rw-r-- 1 ubuntu ubuntu 10 Jul 29 21:31 test.txt
# change directory

sftp>
cd public_html

sftp>
pwd

Remote working directory: /home/vervet/public_html
# upload a file to remote server

sftp>
put test.txt ubuntu.txt

Uploading test.txt to /home/vervet/ubuntu.txt
test.txt 100% 10 0.0KB/s 00:00
sftp>
ls -l

drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:33 public_html
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:39 ubuntu.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 28 22:53 test.txt
# upload some files to remote server

sftp>
put *.txt

Uploading test.txt to /home/vervet/test.txt
test.txt 100% 10 0.0KB/s 00:00
Uploading test2.txt to /home/vervet/test2.txt
test2.txt 100% 0 0.0KB/s 00:00
sftp>
ls -l

drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:33 public_html
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:39 ubuntu.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:45 test.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:46 test2.txt
# download a file from remote server

sftp>
get test.txt

Fetching /home/vervet/test.txt to test.txt
/home/vervet/test.txt 100% 10 0.0KB/s 00:00
# download some files from remote server

sftp>
get *.txt

Fetching /home/vervet/ubuntu.txt to ubuntu.txt
/home/vervet/ubuntu.txt 100% 10 0.0KB/s 00:00
Fetching /home/vervet/test.txt to test.txt
/home/vervet/test.txt 100% 10 0.0KB/s 00:00
Fetching /home/vervet/test2.txt to test2.txt
/home/vervet/test2.txt 100% 10 0.0KB/s 00:00
# create a directory on remote server

sftp>
mkdir testdir

sftp>
ls -l

drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:33 public_html
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:39 ubuntu.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:45 test.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:46 test2.txt
drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:53 testdir
# delete a directory on remote server

sftp>
rmdir testdir

rmdir ok, `testdir' removed
sftp>
ls -l

drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:33 public_html
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:39 ubuntu.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:45 test.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:46 test2.txt
# delete a file on remote server

sftp>
rm test2.txt

Removing /home/vervet/test2.txt
sftp>
ls -l

drwxrwxr-x    2 vervet     vervet            6 Jul 29 21:33 public_html
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:39 ubuntu.txt
-rw-rw-r--    1 vervet     vervet           10 Jul 29 21:45 test.txt
# execute commands with "![command]"

sftp>
!cat /etc/passwd

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
...
...
ubuntu:x:1001:1001::/home/ubuntu:/bin/bash
# exit

sftp>
quit

221 Goodbye.
Matched Content