Transfer file via SSH between the two servers without passwords?

There are two CentOS servers. Both authorization keys

How to send file between them nepamatuju via scp? I connect via putty
Found the solution when only one authorization key, and to have two at once - not seen
March 19th 20 at 09:09
1 answer
March 19th 20 at 09:11
well set up ssh keys from servers advertise first to second and from second server on first. And throw files.

Actually it is not very clear where you have a problem - give an example of what you're trying to do and exactly what comes out.

Examples:
1
I go to server1 as user1.
Write scp file user2@server2

1
I go to server2 as user2.
Write scp file user1@server1
This is on server2
5c9df29dc8092142876857.jpeg - Donnell_OHara commented on March 19th 20 at 09:14
[root@ip-172-26-9-71 ~]# scp dump.sql.gz root@x.x.x.x:/root/dump.sql.gz
The authenticity of host 'x.x.x.x (x.x.x.x)' can't be established.
ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXX.
ECDSA key fingerprint is MD5:XXXXXXXXXXXXXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'x.x.x.x' (ECDSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
lost connection


it is with server1 - Donnell_OHara commented on March 19th 20 at 09:17
If you share the dumps of the database, you should look in the direction of the rsync.
On my work machine with it to collect backups from servers, and a separate script raise backup on the LAN - Luz23 commented on March 19th 20 at 09:20
@Luz23, this utility is no keys to work?
I'm afraid I will again give an error Permission denied (publickey,gssapi-keyex,gssapi-with-mic). - Donnell_OHara commented on March 19th 20 at 09:23
I see you got a permission denied.

* Have user centos exactly have rights to write to the specified folder /root?
* Add-v flag for more details
* The right to a private key you have? - brant.Beat commented on March 19th 20 at 09:26
scp dump.sql.gz root@x.x.x.x:/root/dump.sql.gz


It is not good. Atvykite login anywhere under root. Many systems are configured to generally block the attempted login under root.
Configure the keys of a particular user, under which everything will be copied. - brant.Beat commented on March 19th 20 at 09:29
@brant.Beat,
error permission denied do me everywhere and stalking

1. have user centos not, but I'm under the root do it. In the first screenshot I made a mistake and entered centos. Below, you can see that enter root
2. Performed on сервере2
[root@ip-172-26-14-166 ~]# scp-v root@server1:/root/dump.sql.gz /root/dump.sql.gz 
Executing: program /usr/bin/ssh host server1, user root, command scp-v-f /root/dump.sql.gz
OpenSSH_7.4p1, OpenSSL 1.0.2 k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to server1 [server1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to server1:22 as 'root'
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: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:fhHtF0yjw/CFXUZOyh9hwdEY2criSxyjgexd8UAlD4w
debug1: Host 'server1' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
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: received SSH2_MSG_EXT_INFO
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
[root@ip-172-26-14-166 ~]#


3. I don't know what to answer. I am very poorly familiar with unix - Donnell_OHara commented on March 19th 20 at 09:32
@brant.Beat,
On сервере1

[root@ip-172-26-9-71 ~]# scp-v dump.sql.gz root@server2:/root/dump.sql.gz
Executing: program /usr/bin/ssh host server2, user root, command scp-v -t /root/dump.sql.gz
OpenSSH_7.4p1, OpenSSL 1.0.2 k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to server2 [server2] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to server2:22 as 'root'
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: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:JXpYxZDD8En7607iEjPwlJcbHsJNWuXokqrqw0xnd3m
debug1: Host 'server2' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
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: received SSH2_MSG_EXT_INFO
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
lost connection
[root@ip-172-26-9-71 ~]#
- Donnell_OHara commented on March 19th 20 at 09:35
Generally made of stupid. Generated on сервере2 public key owner has copied the content and pasted on server1 and copied the data while in сервере2 - Donnell_OHara commented on March 19th 20 at 09:38
Well, you need to do.
Can the same keys, and Vice versa to put the private key on server1 in the /root/.ssh/
And public on server2 in the /root/.ssh/authorized_keys to add. - brant.Beat commented on March 19th 20 at 09:41

Find more questions by tags PuTTYSSH