@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for '/home/root/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/root/.ssh/id_rsa
git@172.16.98.152's password: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

使用两个ssh工具连接远程服务器,NX和putty,连接的时候偶然发现这个错误,说key文件权限太大,估计是key文件的属性被改的问题;
后来上网查了,把权限改成600即可

chmod  600  /home/xiaoqiang.he/.ssh/*

http://blog.chinaunix.net/uid-26952464-id-3699864.html

[admin@ip-localhost ~]$
[admin@ip-localhost ~]$ !scp
scp -i key/admin.pem bak.tar.gz admin@192.168.1.200:/
ssh: connect to host 192.168.1.200 port : Connection timed out //此处报错是因为firewall没有accept端口
lost connection
[admin@ip-localhost ~]$ scp -i key/admin.pem bak.tar.gz admin@192.168.1.100:/home/admin
The authenticity of host '192.168.1.100 (192.168.1.100)' can't be established.
ECDSA key fingerprint is ::d4:c5:8e::fa::fa::bc:d8:8a:5d:bb:8a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.100' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'key/admin.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: key/admin.pem
Permission denied (publickey).
lost connection
[admin@ip-localhost ~]$ ll key/admin.pem
-rw-rw-r-- admin admin Dec : key/admin.pem
[admin@ip-localhost ~]$
[admin@ip-localhost ~]$
[admin@ip-localhost ~]$ chmod 600 key/admin.pem
[admin@ip-localhost ~]$
[admin@ip-localhost ~]$
[admin@ip-localhost ~]$
[admin@ip-localhost ~]$ scp -i key/admin.pem bak.tar.gz admin@192.168.1.100:/home/admin
bak.tar.gz % 1016MB .9MB/s :
[admin@ip-localhost ~]$

http://stackoverflow.com/questions/6558080/scp-secure-copy-to-ec2-instance-without-password?rq=1

Below is what I used and it worked. Source was ec2 and target was home machine.

 sudo rsync  -azvv -e "ssh -i /home/ubuntu/key-to-ec2.pem" ec2-user@xx.xxx.xxx.xx:/home/ec2-user/source/ /home/ubuntu/target/

This worked for me:

nohup rsync -zravu --partial --progress  -e "ssh -i xxxx.pem" ubuntu@xx.xx.xx.xx:/mnt/data   /mnt2/ &

After suffering a little bit, I believe this will help:

I am using the below command and it has worked without problems:

rsync -av --progress -e ssh /folder1/folder2/* root@xxx.xxx.xxx.xxx:/folder1/folder2

First consideration:

Use the --rsync-path

I prefer in a shell script:

#!/bin/bash

RSYNC = /usr/bin/rsync

$RSYNC [options] [source] [destination]

Second consideration:

Create a publick key by command below for communication between the servers in question. She will not be the same as provided by Amazon.

ssh-keygen -t rsa

Do not forget to enable permission on the target server in /etc/ssh/sshd_config (UBUNTU and CENTOS).

Sync files from one EC2 instance to another

http://ask-leo.com/how_can_i_automate_an_sftp_transfer_between_two_servers.html

Use -v option for verbose and better identify errors.

Third Consideration

If both servers are on EC2 make a restraint by security group

In the security group Server Destination:

inbound: Source / TCP port 22 / IP Security (or group name) of the source server

http://stackoverflow.com/questions/6558080/scp-secure-copy-to-ec2-instance-without-password?rq=1

http://stackoverflow.com/questions/15843195/rsync-to-amazon-ec2-instance

https://askleo.com/how_can_i_automate_an_sftp_transfer_between_two_servers/

No, not correct.
As it turns out, this is something I do regularly with ssh, as well as both sftp and rsync, as part of my backup and load balancing approaches for Ask Leo! Let me walk you through what I’ve done.

SSH Configuration
To begin with, most of this relies on a the configuration of sshd, the SSH (Secure SHell) daemon running on the server you’re attempting to connect to (we’ll call it “server2.com”). Check the “sshd_config” on that server, typically in /etc/ssh. In some cases, these settings are not always present or set the way we need:
RSAAuthentication yes
PubkeyAuthentication yes
This enables the public/private key authentication mechanism we’re about to use.
Public/Private Key Generation
We’ll generate the keypair on the Linux box that you want to connect from. We’ll call that “server1.com”. It’s that box on which you plan to run ssh, sftp or rsync.
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user1/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .ssh/id_rsa.
Your public key has been saved in .ssh/id_rsa.pub.
The key fingerprint is:
c1:21:e 3:01:26:0d:f7:ec:52:0e:0c:90:9b:6e:d8:47 user1@server1.com
What I’ve done with the command above is generated a public/private key pair. I responded to each prompt by hitting Return.

…mere possession of the private key is sufficient to gain access to what ever resources into which you’ve placed the corresponding public key.
Note that I did NOT enter a passphrase. That’s kind of important, because if you do enter a passphrase you’ll need to enter it in order to use the private key. Since we’re looking for an automated solution, the private key must not have a passphrase.
This is important: by not placing a passphrase on your private key, the security implication is that mere possession of the private key is sufficient to gain access to what ever resources into which you’ve placed the corresponding public key. Safeguard your private key.
My private key was placed in /home/user1/.ssh/id_rsa. This needs to be kept secure, because of the security implication above, but also needs to be available to the process attempting to make an ssh, sftp or rsync connection. If these tools are run under the ‘user1’ account, the tools will automatically look in the “.ssh” directory and I won’t need to specify the private key location. Otherwise, command line options will need to point to the right place and key.
My public key is in /home/user1/.ssh/id_rsa.pub. This is the key that gets distributed to those places that want to grant you access.
Planting the public key
On the “remote” server, server2.com, pick an account – ANY account – that you want to connect as. In that account’s home directory, create a “.ssh” subdirectory, and in that directory create a new text file called “authorized_keys”. If it already exists, that’s fine, use the existing file.
If you create the file and/or directory, I recommend that the directory be chmod 700, and the file 600. In other words, only the owner can access the directory, and the file within it.
Add to that file the contents of the id_rsa.pub file created above. That would be a *single line* that looks something like this:
ssh-rsa <lots of characters> user1@server1.com
Once saved anyone in possession of the private key that matches this public key can now login as this account.
sftp
I planted the public key in the account user2 on server2.com. So now, on my server, server1.com, logged in as user1, and where the private key is stored as described above, an sftp session looks like this:
sftp user2@server2.com
“user2” specifies the remote account on server2.com to login as.
That’s it. Magic happens, and I’m authenticated. That magic? The private key is matched to the public key, which indicates you are authorized to login to that account. An sftp session is born. No interactivity required.
(IF you did enter a passphrase on the private key, you would have been prompted to enter it here. NOTE that this is the passphrase to unlock the private key, which is local. It has nothing to do with any passwords on the remote site.)
rsync
For file copy operations, rsync rocks. It does things like intelligent compression, copy only if needed, and a whole host of other operations.
So, assuming all the keys are set up as above, this rsync command copies a file from the local machine to the remote:
rsync -e ssh file user2@server2.com:/home/user2/
Local file “file” is copied to the remote /home/user2/file after logging in as “user2” using ssh as the transport (hence the “-e ssh” option), and with that, using the private/public key pair we created for authentication. Again, no interactivity required.
Rsync supports an incredibly rich set of options for recursion, compression attribute retention, date/time stamp and so on. Well worth a look see if you’re copying anything of any significant volume.
SSH
Since we’ve gone this far, it’s worth noting that SSH itself just works as well to open up a remote shell once the keys are in place. Example:
ssh user2@server2.com
and *poof* – a remote shell on server2, logged in as user2.

https://askleo.com/how_can_i_automate_an_sftp_transfer_between_two_servers/

Permissions 0664 for '/home/root/.ssh/id_rsa' are too open.的更多相关文章

  1. ssh:Permissions 0644 for ‘/root/.ssh/id_rsa’ are too open

    最近,用ssh连接github时,突然提示“Permissions 0644 for ‘/root/.ssh/id_rsa’ are too open”,并且断开连接. 仔细阅读了一下ssh文档和这句 ...

  2. Permissions 0755 for '/home/lonecloud/.ssh/id_rsa' are too open.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! ...

  3. git Permissions 0777 for '/home/xxx/.ssh/id_rsa' are too open.

    使用 git 时出现下面的问题,原因是 git 公钥的权限被修改了. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WAR ...

  4. ansible Failed to connect to the host via ssh: no such identity: /root/.ssh/id_rsa.bak

    中控机和远端主机配置完密钥后,在中控台上通过ansible检测联通性 ansible -i inventory.cfg all -m ping 10.1.1.1 | UNREACHABLE! => ...

  5. ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3

    ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3

  6. ssh-keygen -t rsa P “” -f ~/.ssh/id_rsa不提示直接生成密钥

    ssh-keygen -t rsa P "" -f ~/.ssh/id_rsa不提示直接生成密钥

  7. ssh-copy-id -i ~/.ssh/id_rsa.pub admin@172.17.42.66

    ssh-copy-id -i ~/.ssh/id_rsa.pub admin@172.17.42.66

  8. root权限下找不到 /root/.ssh目录

    Xshell配置ssh登陆远程服务器,找不到 root/.ssh目录,报错信息如下: root@ubuntu:/home/xinxin# cd /root/.ssh/bash: cd: /root/. ...

  9. Add correct host key in /root/.ssh/known_hosts to get rid of this message

    bug: Add correct host key in /root/.ssh/known_hosts to get rid of this message 解决办法: rm ~/.ssh/known ...

随机推荐

  1. Mybatis resultMap空值映射问题解决

    Mybatis在使用resultMap来映射查询结果中的列,如果查询结果中包含空值的列(不是null),则Mybatis在映射的时候,不会映射这个字段,例如 查询 name,sex,age,数据库中的 ...

  2. CSS权威指南 - 浮动和定位 1

    定位 定位的想法很简单元素框相对于正常位置出现在哪里. 定位:static,相对, 绝对, fixed, 继承 static就是默认的位置 相对就是相对于默认位置的偏移.原来的static定位位置依然 ...

  3. PHP 开发 APP 接口 学习笔记与总结 - APP 接口实例 [6] 版本升级接口开发

    判定 app 是否需要加密:通过 app 表中的 status 字段来判定,加密的字符串为 app 表中的 key 字段. 在获取的客户端和服务器端(数据库表中相应字段)的版本号不一致时,返回 dat ...

  4. [SHELL实例] (转)最牛B的 Linux Shell 命令 (一)

    本文编译自commandlinefu.com ( 应该是 Catonmat ) 的系列文章 Top Ten One-Liners from CommandLineFu Explained .作为一个由 ...

  5. MySQL服务器状态变量

    一,最值得检查的状态变量使用show global status进行检测二.变量部分1.Aborted_clients如果这个变量持续增加,确定连接是否被关闭了.如果不是检查网络性能,并且检查max_ ...

  6. Andrew Ng机器学习公开课笔记 -- Online Learning

    网易公开课,第11课 notes,http://cs229.stanford.edu/notes/cs229-notes6.pdf   和之前看到的batch learning算法不一样,batch ...

  7. 批处理快速创建wifi

    为什么要用cmd这种古老的东西创建wifi呢,电脑管家.360安全卫士都有这种插件,一键开启关闭,多方便啊! 开始用的也是电脑管家的免费wifi插件,但是我越来越不能忍它极慢的启动关闭过程,每一次看着 ...

  8. ucenter小结

    经历了一天的折腾,大概搞清楚的ucenter接入应用的方法.总结如下: 一.下载安装ucenter.这个很简单. 二.然后就是接入应用. 1.先在你项目的根目录copy一份uc_client文件夹. ...

  9. toast 防止一直不停弹出,累积显示

    private Toast mToast = null; public void showTextToast(String msg) { if (mToast == null) { mToast = ...

  10. html之内联元素与块状元素;

    html之内联元素与块状元素 一.html之内联元素与块状元素 1.块状元素一般比较霸道,它排斥与其他元素位于同一行内.比如div,并且width与height对它起作用. 2.内联元素只能容纳文本或 ...