WHAT’S SCP – HOW TO DOWNLOAD/UPLOAD FILE OR FOLDER USING SCP COMMAND IN LINUX

In this post i’m going to show you how scp command works in linux .

SCP (secure copy ) is a combination of ssh server and cp (copy) . Ssh provides authentication ( secure line ) and cp is used to copy files from one system to another . SSH is best for transferring files from one servers to client or servers in a secure way . Ssh provides Sometimes its very hard to transfer files or folders to other machine through any servers . Like their servers settings are not configured properly or some package are not installed or either having problem in connecting through servers . That’s where scp is mostly used .  It works on port 22 tcp .

 

HOW TO UPLOAD FILE OR FOLDER USING SCP COMMAND IN LINUX

  • First i’ll check which file i have to transfer . By ls command you can check files and folders in that directory .
[root@localhost ~]# ls
3usageeks                                                install.log
3.zip                                                    install.log.syslog
anaconda-ks.cfg                                          lynis-1.3.0.tar.gz
avg85flx-r287-a2632.i386.rpm                             rhel54iso.iso
Cisco Packet Tracer 6.2 for Windows Student Version.exe  rkhunter
crossover-pro-9.0.0-1.i386 (1).rpm                       rkhunter-1.4.0.tar.gz
Deepit                                                   webmin-1.580-1.noarch.rpm
Desktop
  • I’m sending rk hunter folder to another machine .
  • You should also know the ip address of client machine .
  • First type  scp  -rv
  • Second folder or file name which you want to transfer .
  • Then ip address to whom you want to send this folder and also give the path .
  • I’m uploading rkhunter folder to server (192.168.43.175) . Then put separate (:) after that path to its Desktop .
[root@localhost ~]# scp -rv rkhunter 192.168.43.175:/root/Desktop/
Executing: program /usr/bin/ssh host 192.168.43.175, user (unspecified), command scp -v -r -t /root/Desktop/
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.43.175 [192.168.43.175] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.43.175' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
root@192.168.43.175's password:
  • You need to ask password of client for sending folder . Give correct password to send copy of that folder .
  • After you give correct password transferring process will start .
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -r -t /root/Desktop/
Entering directory: D0775 0 rkhunter-1.4.0
Sink: D0775 0 rkhunter-1.4.0
Entering directory: D0750 0 files
Sink: D0750 0 files
Entering directory: D0750 0 tools
Sink: D0750 0 tools
Sink: E
Sending file modes: C0640 6103 rkhunter.spec
Sink: C0640 6103 rkhunter.spec
rkhunter.spec                                                               100% 6103     6.0KB/s   00:00
Sending file modes: C0640 97 mirrors.dat
Sink: C0640 97 mirrors.dat
mirrors.dat                                                                 100%   97     0.1KB/s   00:00
Sending file modes: C0640 1055 backdoorports.dat
Sink: C0640 1055 backdoorports.dat
backdoorports.dat                                                           100% 1055     1.0KB/s   00:00
Entering directory: D0750 0 development
Sink: D0750 0 development
Sending file modes: C0640 5314 new-OS-support
Sink: C0640 5314 new-OS-support
new-OS-support                                                              100% 5314     5.2KB/s   00:00
Sending file modes: C0750 1925 i18nchk
Sink: C0750 1925 i18nchk
i18nchk                                                                     100% 1925     1.9KB/s   00:00
Sink: E
Sending file modes: C0750 1894 check_modules.pl
Sink: C0750 1894 check_modules.pl
check_modules.pl                                                            100% 1894     1.9KB/s   00:00
Sending file modes: C0640 37192 rkhunter.conf
Sink: C0640 37192 rkhunter.conf
rkhunter.conf                                                               100%   36KB  36.3KB/s   00:00
Sending file modes: C0640 26561 FAQ
Sink: C0640 26561 FAQ
FAQ                                                                         100%   26KB  25.9KB/s   00:00
Entering directory: D0750 0 i18n
Sink: D0750 0 i18n
Sending file modes: C0640 28735 cn
Sink: C0640 28735 cn
cn                                                                          100%   28KB  28.1KB/s   00:00
Sending file modes: C0640 24257 zh
Sink: C0640 24257 zh
zh                                                                          100%   24KB  23.7KB/s   00:00
Sending file modes: C0640 36074 en
Sink: C0640 36074 en
en                                                                          100%   35KB  35.2KB/s   00:00
Sending file modes: C0640 28611 zh.utf8
Sink: C0640 28611 zh.utf8
zh.utf8                                                                     100%   28KB  27.9KB/s   00:00
Sending file modes: C0640 35893 de
Sink: C0640 35893 de
de                                                                          100%   35KB  35.1KB/s   00:00
Sink: E
Sending file modes: C0640 18010 LICENSE
Sink: C0640 18010 LICENSE
LICENSE                                                                     100%   18KB  17.6KB/s   00:00
Sending file modes: C0640 1904 suspscan.dat
Sink: C0640 1904 suspscan.dat
suspscan.dat                                                                100% 1904     1.9KB/s   00:00
Sending file modes: C0750 689 filehashsha.pl
Sink: C0750 689 filehashsha.pl
filehashsha.pl                                                              100%  689     0.7KB/s   00:00
Sending file modes: C0750 3227 readlink.sh
Sink: C0750 3227 readlink.sh
readlink.sh                                                                 100% 3227     3.2KB/s   00:00
Sending file modes: C0750 3091 stat.pl
Sink: C0750 3091 stat.pl
stat.pl                                                                     100% 3091     3.0KB/s   00:00
Entering directory: D0750 0 testing
Sink: D0750 0 testing
Sink: E
Sending file modes: C0640 20015 rkhunter.8
Sink: C0640 20015 rkhunter.8
rkhunter.8                                                                  100%   20KB  19.6KB/s   00:00
Sending file modes: C0640 3203 programs_bad.dat
Sink: C0640 3203 programs_bad.dat
programs_bad.dat                                                            100% 3203     3.1KB/s   00:00
Sending file modes: C0640 88711 CHANGELOG
Sink: C0640 88711 CHANGELOG
CHANGELOG                                                                   100%   87KB  86.6KB/s   00:00
Sending file modes: C0640 1306 ACKNOWLEDGMENTS
Sink: C0640 1306 ACKNOWLEDGMENTS
ACKNOWLEDGMENTS                                                             100% 1306     1.3KB/s   00:00
Sending file modes: C0640 33456 README
Sink: C0640 33456 README
README                                                                      100%   33KB  32.7KB/s   00:00
Entering directory: D0750 0 contrib
Sink: D0750 0 contrib
Sending file modes: C0640 3445 rkhunter_remote_howto.txt
Sink: C0640 3445 rkhunter_remote_howto.txt
rkhunter_remote_howto.txt                                                   100% 3445     3.4KB/s   00:00
Sending file modes: C0640 547 README.txt
Sink: C0640 547 README.txt
README.txt                                                                  100%  547     0.5KB/s   00:00
Sending file modes: C0640 2752 run_rkhunter.sh
Sink: C0640 2752 run_rkhunter.sh
run_rkhunter.sh                                                             100% 2752     2.7KB/s   00:00
Sink: E
Sending file modes: C0750 491628 rkhunter
Sink: C0750 491628 rkhunter
rkhunter                                                                    100%  480KB 480.1KB/s   00:00
Sink: E
Sending file modes: C0777 32839 installer.sh
Sink: C0777 32839 installer.sh
installer.sh                                                                100%   32KB  32.1KB/s   00:00
Sink: E
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 2.3 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0

desktop of linux

Client can see rkhunter folder has been uploaded on its Desktop

HOW TO DOWNLOAD FILE OR FOLDER USING SCP COMMAND IN LINUX

  • Command is almost same .
  • First type scp  -rv
  • Second ip address of server machine then separate (:) After that file or folder where its located in server machine .
  • Third where you want file or folder to be stored in your system
  •  like i’m downloading from linux machine having ip address 192.168.43.175 :
  • I want rkh folder and its located on his Desktop
  • Then path where you want it to be downloaded . I too want it on my Desktop .
[root@localhost ~]# scp -rv 192.168.43.175:/root/Desktop/rkh /root/Desktop/
Executing: program /usr/bin/ssh host 192.168.43.175, user (unspecified), command scp -v -r -f /root/Desktop/rkh
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.43.175 [192.168.43.175] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.43.175' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
root@192.168.43.175's password:
  • Give password of the machine from where you are taking file or folder
  • After giving correct password process will start .
  • Within few seconds , Rkh folder will be on my desktop .
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -r -f /root/Desktop/rkh
Entering directory: D0775 0 rkh
Sink: D0775 0 rkh
Sending file modes: C0755 32839 installer.sh
Sink: C0755 32839 installer.sh
installer.sh                                                                100%   32KB  32.1KB/s   00:00
Entering directory: D0750 0 files
Sink: D0750 0 files
Sending file modes: C0640 1904 suspscan.dat
Sink: C0640 1904 suspscan.dat
suspscan.dat                                                                100% 1904     1.9KB/s   00:00
Entering directory: D0750 0 i18n
Sink: D0750 0 i18n
Sending file modes: C0640 24257 zh
Sink: C0640 24257 zh
zh                                                                          100%   24KB  23.7KB/s   00:00
Sending file modes: C0640 28611 zh.utf8
Sink: C0640 28611 zh.utf8
zh.utf8                                                                     100%   28KB  27.9KB/s   00:00
Sending file modes: C0640 35893 de
Sink: C0640 35893 de
de                                                                          100%   35KB  35.1KB/s   00:00
Sending file modes: C0640 28735 cn
Sink: C0640 28735 cn
cn                                                                          100%   28KB  28.1KB/s   00:00
Sending file modes: C0640 36074 en
Sink: C0640 36074 en
en                                                                          100%   35KB  35.2KB/s   00:00
Sink: E
Sending file modes: C0640 1306 ACKNOWLEDGMENTS
Sink: C0640 1306 ACKNOWLEDGMENTS
ACKNOWLEDGMENTS                                                             100% 1306     1.3KB/s   00:00
Sending file modes: C0640 1055 backdoorports.dat
Sink: C0640 1055 backdoorports.dat
backdoorports.dat                                                           100% 1055     1.0KB/s   00:00
Sending file modes: C0640 88711 CHANGELOG
Sink: C0640 88711 CHANGELOG
CHANGELOG                                                                   100%   87KB  86.6KB/s   00:00
Sending file modes: C0750 3227 readlink.sh
Sink: C0750 3227 readlink.sh
readlink.sh                                                                 100% 3227     3.2KB/s   00:00
Sending file modes: C0750 491628 rkhunter
Sink: C0750 491628 rkhunter
rkhunter                                                                    100%  480KB 480.1KB/s   00:00
Sending file modes: C0750 1894 check_modules.pl
Sink: C0750 1894 check_modules.pl
check_modules.pl                                                            100% 1894     1.9KB/s   00:00
Sending file modes: C0640 6103 rkhunter.spec
Sink: C0640 6103 rkhunter.spec
rkhunter.spec                                                               100% 6103     6.0KB/s   00:00
Sending file modes: C0640 3203 programs_bad.dat
Sink: C0640 3203 programs_bad.dat
programs_bad.dat                                                            100% 3203     3.1KB/s   00:00
Sending file modes: C0640 97 mirrors.dat
Sink: C0640 97 mirrors.dat
mirrors.dat                                                                 100%   97     0.1KB/s   00:00
Entering directory: D0750 0 contrib
Sink: D0750 0 contrib
Sending file modes: C0640 2752 run_rkhunter.sh
Sink: C0640 2752 run_rkhunter.sh
run_rkhunter.sh                                                             100% 2752     2.7KB/s   00:00
Sending file modes: C0640 547 README.txt
Sink: C0640 547 README.txt
README.txt                                                                  100%  547     0.5KB/s   00:00
Sending file modes: C0640 3445 rkhunter_remote_howto.txt
Sink: C0640 3445 rkhunter_remote_howto.txt
rkhunter_remote_howto.txt                                                   100% 3445     3.4KB/s   00:00
Sink: E
Sending file modes: C0640 26561 FAQ
Sink: C0640 26561 FAQ
FAQ                                                                         100%   26KB  25.9KB/s   00:00
Sending file modes: C0640 37192 rkhunter.conf
Sink: C0640 37192 rkhunter.conf
rkhunter.conf                                                               100%   36KB  36.3KB/s   00:00
Sending file modes: C0640 20015 rkhunter.8
Sink: C0640 20015 rkhunter.8
rkhunter.8                                                                  100%   20KB  19.6KB/s   00:00
Entering directory: D0750 0 development
Sink: D0750 0 development
Sending file modes: C0640 5314 new-OS-support
Sink: C0640 5314 new-OS-support
new-OS-support                                                              100% 5314     5.2KB/s   00:00
Sending file modes: C0750 1925 i18nchk
Sink: C0750 1925 i18nchk
i18nchk                                                                     100% 1925     1.9KB/s   00:00
Sink: E
Entering directory: D0750 0 tools
Sink: D0750 0 tools
Sink: E
Sending file modes: C0640 18010 LICENSE
Sink: C0640 18010 LICENSE
LICENSE                                                                     100%   18KB  17.6KB/s   00:00
Sending file modes: C0750 3091 stat.pl
Sink: C0750 3091 stat.pl
stat.pl                                                                     100% 3091     3.0KB/s   00:00
Entering directory: D0750 0 testing
Sink: D0750 0 testing
Sink: E
Sending file modes: C0640 33456 README
Sink: C0640 33456 README
README                                                                      100%   33KB  32.7KB/s   00:00
Sending file modes: C0750 689 filehashsha.pl
Sink: C0750 689 filehashsha.pl
filehashsha.pl                                                              100%  689     0.7KB/s   00:00
Sink: E
Sink: E
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 1.8 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
[root@localhost ~]#
  • I’m gonna check whether rkh folder is downloaded or not .
  • Go to Desktop and type ls command .
[root@localhost ~]# cd /root/Desktop/
[root@localhost Desktop]# ls
a.txt  Cisco+Packet+Tracer+Student.desktop  d.txt  d.txt~  h.txt  
h.txt~  rkh  Server

 

HOW TO INSTALL WINDOWS SOFTWARE IN LINUX THROUGH CROSSOVER .

HOW TO CREATE VIRTUAL IP ADDRESS AND CONFIGURE APACHE VIRTUAL HOSTING IN LINUX .

SSH SERVER – HOW TO CONFIGURE SSH SERVER ON LINUX AS SERVER AND WINDOWS,LINUX,ANDROID OR IOS AS CLIENT .

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s