Comando SCP no Linux

Standard

Secure Copy ou SCP é um meio seguro para transferir arquivos entre um host local e um remoto ou entre dois hosts remotos, usando o protocolo SSH.

O termo SCP pode ao mesmo tempo referir-se ao Protocolo SCP ou ao Programa SCP.

Sintaxe do comando:

scp /ArquivoFonte usuário@host:/diretório/ArquivoAlvo
scp usuário@host:/diretório/ArquivoFonte /ArquivoAlvo

Segue abaixo alguns Exemplos de uso do programa SCP na linha de comando no linux:

– Dentro do diretório:
$ scp arquivo usuario@192.168.1.2:/home/usuario

– Fora do diretório:

$ scp /home/usuário/arquivo usuario@192.168.1.2:/home/usuario

– Especificar a porta com o parâmetro -P:
$ scp -P 22 arquivo usuario@192.168.1.2:/home/usuario

– Habilitando modo verbose:

$ scp -vP 22 arquivo.jpg usuario@192.168.1.2:/home/usuario

Executing: program /usr/bin/ssh host 192.168.1.2, user usuario, command scp -v -t — /home/usuario

OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Applying options for *

debug1: Connecting to 192.168.1.2 [10.168.1.2] port 22.

debug1: Connection established.

debug1: identity file /home/usuario/.ssh/id_rsa type -1

debug1: identity file /home/usuario/.ssh/id_rsa-cert type -1

debug1: identity file /home/usuario/.ssh/id_dsa type -1

debug1: identity file /home/usuario/.ssh/id_dsa-cert type -1

debug1: identity file /home/usuario/.ssh/id_ecdsa type -1

debug1: identity file /home/usuario/.ssh/id_ecdsa-cert type -1

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6

debug1: match: OpenSSH_5.5p1 Debian-6 pat OpenSSH*

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: server->client aes128-ctr hmac-md5 none

debug1: kex: client->server aes128-ctr 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: Server host key: RSA 45:ff:aa:e3:f2:a1:12:ac:56:cd:6e:6a:44:aa:ff:67

debug1: Host ‘192.168.1.2’ is known and matches the RSA host key.

debug1: Found key in /home/usuario/.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: Roaming not allowed by server

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug1: Authentications that can continue: publickey,password

debug1: Next authentication method: publickey

debug1: Trying private key: /home/usuario/.ssh/id_rsa

debug1: Trying private key: /home/usuario/.ssh/id_dsa

debug1: Trying private key: /home/usuario/.ssh/id_ecdsa

debug1: Next authentication method: password

usuario@192.168.1.2’s password:

debug1: Authentication succeeded (password).

Authenticated to 192.168.1.2 ([192.168.1.2]:22).

debug1: channel 0: new [client-session]

debug1: Requesting no-more-sessions@openssh.com

debug1: Entering interactive session.

debug1: Sending environment.

debug1: Sending env LANG = pt_BR.UTF-8

debug1: Sending command: scp -v -t — /home/usuario

Sending file modes: C0644 18456 arquivo.jpg

Sink: C0644 18456 arquivo.jpg

arquivo.jpg                                                                                                                                                            100%   18KB  18.0KB/s   00:00

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

Transferred: sent 20400, received 2072 bytes, in 0.1 seconds

Bytes per second: sent 196905.4, received 19999.4

debug1: Exit status 0

 

OBS: Será solicitada a senha do usuário no computador remoto, caso tenha DNS resolvendo nome de rede, pode executar os comandos acima utilizando os nomes ao invés do IP.

Fonte :

http://pt.wikipedia.org/wiki/Unix_SCP

Deixe uma resposta

O seu endereço de email não será publicado. Campos obrigatórios marcados com *