I have this error when using scp:
scp -r h1:/dir1 h2:/dir1
ssh: Could not resolve hostname online1: Name or service not known
lost connection
But both ssh h1
and ssh h2
works well for I have config name alias in .ssh/config like this:
Host h1
HostName 172.16.18.xxx
User xxx
No editing on /etc/hosts. And I also use ssh-copy-id
to work out the public key. Any idea of what's wrong?
One of the added benefits of using ssh's config file is that programs like scp, rsync, and rdiff-backup automatically pick up these options also and work just as you'd expect (hope).
The ssh program on a host receives its configuration from either the command line or from configuration files ~/. ssh/config and /etc/ssh/ssh_config . Command-line options take precedence over configuration files. The user-specific configuration file ~/.
When you use scp with no additional options like you here, remote h1 tries to directly connect to h2.
h1 -> h2
Since h1
need to know who h2
is, h1
needs the definition of h2
. But you could also route it over your PC like
h1 -> your pc -> h2
using the option -3
scp -r -3 h1:/dir1 h2:/dir2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With