Install SCP on CentOS

Linux administrator should be familiar with CLI environment. Since GUI mode in Linux servers is not a common to be installed. SSH may the most popular protocol to enable Linux administrator to manage the servers via remote in secure way. Built-in with SSH command there is SCP command. SCP is used to copy file(s) between servers in secure way.

Hello, my name is Diego Luisi and in today’s article will demonstrate how to install and configure the SCP on Linux machine using the CentOS 6.

When is chosen the "minimal" in the installation of CentOS he does not pop things like rsync and SCP.

1. Install Open SSH-Clients:

# yum install openssh-clients -y

2. Copy a file aviso.txt from 192.168.10.1 to 192.168.10.2:

# scp /etc/ssh/aviso.txt root@192.168.10.2:/etc/ssh/

/etc/ssh/aviso.txt => Source File
root@192.168.10.2: => Destination
/etc/ssh/ => Folder destination

If you need to do this procedure on multiple servers at once, I developed a script to automate this task the only thing you’ll need is to create a list of IP addresses of other servers.

#! /bin/bash
# Script Copia de Arquivos 
# Por Diego Luisi
echo "Script para copia de Arquivos"
echo ""
echo "Digite o caminho completo do arquivo de origem: "
read ORIGEM
echo "Digite o caminho de destino do arquivo: "
read DESTINO
echo "Digite o Arquivo que contem os endereços dos servidores: "
read SERVIDORES
cat $SERVIDORES | while read LINHA; do
echo ""
echo $ORIGEM root@$LINHA:$DESTINO
scp $ORIGEM root@$LINHA:$DESTINO
echo ""
echo ""
done

You may also like...

2 Responses

  1. Ernander says:

    fala meu Amigo! Só para dar uma Ajudinha, nós trocamos as portas padrão para aumentar a segurança, e para tal ao se fazer scp com porta trocada é necessário usar o -P ( maiúsculo ) como segue: scp -P 9999 root@SERVER:/CAMINHO /DESTINO

    Att
    Nander

Leave a Reply

Your email address will not be published. Required fields are marked *