Como usar o IPV4 quando scp entre dois servidores?

1

Eu gostaria de copiar um arquivo com scp do host1 para o host2 executando o comando da minha máquina local. A conexão do host1 ao host2 deve usar o IPV4 porque não há conectividade IPV6 entre o host1 e o host2 (por motivos fora do meu controle).

Na minha máquina local, eu uso:

scp -4 -v -r -o "ForwardAgent=yes" user@host1:myFile user@host2:

Na saída, tenho:

debug1: Connecting to host1 [a.b.c.d] port 22.

que está correto, mas a conexão do host1 para o host2 é tentada com o IPV6:

debug1: Connecting to host2 [a:b:c:d:e:f:g:h] port 22

e falha, porque não há conectividade IPv6.

Como forçar o scp a usar o IPV4 na conexão do host1 ao host2?

P.S .: Eu uso o scp do macOS 10.13.3

==== Editar

Abaixo do log completo. Você pode ver que o problema vem do fato de que quando o comando scp envia o comando do host1 ele não adiciona a opção -4 . Veja a linha:

debug1: Sending command: scp -v -r /myFile user@host2:.

OpenSSH_7.6p1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /Users/user/.ssh/config
debug1: /Users/user/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug1: Connecting to host1 [a.b.c.d] port 22.
debug1: Connection established.
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Debian-10+deb9u3
debug1: match: OpenSSH_7.4p1 Debian-10+deb9u3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to host1:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:/sfbwfbhwh/wsfgwhwthwth
debug1: Host 'host1' is known and matches the ECDSA host key.
debug1: Found key in /Users/user/.ssh/known_hosts:66
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to host1.com ([a.b.c.d]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Requesting authentication agent forwarding.
debug1: Sending command: scp -v -r /myFile user@host2:.
Executing: program /usr/bin/ssh host host2, user user, command scp -v -r -t .
OpenSSH_7.4p1 Debian-10+deb9u3, OpenSSL 1.0.2l  25 May 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to host2 [a:b:c:d:e:f:g:h] port 22.
    
por Ortomala Lokni 20.03.2018 / 15:04

2 respostas

2

Tente usar: scp -4 -v -r -o "ForwardAgent=yes" user@host1:myFile [email protected] :

Onde d.e.f.g é o endereço IPv4 do host2. E verifique seu DNS, por favor, ele retornará os endereços corretos.

    
por 20.03.2018 / 15:34
0

Isso deve ser feito. Espero ter entendido corretamente:)

$ rsync -rav --ipv4 /tmp/f.txt  someuser@dev1:/home/someuser

de man rsync

 -v, --verbose               increase verbosity
 -a, --archive               archive mode; same as -rlptgoD (no -H)
 -r, --recursive             recurse into directories
 -4, --ipv4                  prefer IPv4
    
por 20.03.2018 / 15:22

Tags