Ita*_*not 1 linux ssh-keys centos6
我需要创建一个 cron 脚本,它将所有日志从一台机器 scp 到日志解析机器,但是当我 scp 时,我被要求插入密码。通常,当我使用 Putty 连接到服务器时,我使用pageantPutty 来允许代理转发,当我选择要连接的机器时,它会打开一个 Putty 窗口,让我直接进入 shell,无需插入密码。在我将 rsa 公钥插入每台机器上的 .ssh/authorized_keys 文件后,就会发生这种情况。
我想在两台服务器之间做同样的事情。
编辑:我不知道为什么它被否决了......我认为这是一个合理的问题。请告诉我我做错了什么:
[root@search-uk-1 .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
ca:ab:4d:95:a4:ee:47:67:0c:e1:23:f3:73:46:67:7e root@search-uk-1.int.incredimail.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . |
| ... |
| oo+.. o |
| .+S= + |
| o o+ * . E |
| =. * . |
| + .. |
| ..+. |
+-----------------+
[root@search-uk-1 .ssh]# ssh-copy-id root@sawmill
root@sawmill's password:
Now try logging into the machine, with "ssh 'root@sawmill'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@search-uk-1 .ssh]# ssh root@sawmill
Enter passphrase for key '/root/.ssh/id_rsa':
Last login: Mon Nov 5 11:32:33 2012 from search-uk-1.int.incredimail.com
[root@sawmill ~]# exit
logout
Connection to sawmill closed.
[root@search-uk-1 .ssh]# ssh root@sawmill
Enter passphrase for key '/root/.ssh/id_rsa':
Run Code Online (Sandbox Code Playgroud)
即使我从 .pub 文件中复制了 rsa 密钥并将其粘贴到远程机器上 .ssh/authorized_keys 它仍然不断要求我输入密码。
谢谢
我很简单。在机器上生成您的 rsa_idssh-keygen -t rsa
之后只需执行ssh-copy-id login@secondmachineput password 就可以了。之后,您应该能够在没有密码的情况下从一台机器登录到另一台机器(如果您想在两台机器上都没有密码登录,那么您应该在第二台机器上执行相同的步骤)。
但也许您应该考虑将 rsync 用于此作业。使用环境变量 USER 和 RSYNC_PASSWORD 在 cronjobs 中使用密码进行 rsync 非常简单。把它放在你的脚本中
export USER=nameofrsyncuser
export RSYNC_PASSWORD=password
Run Code Online (Sandbox Code Playgroud)
之后,任何 rsync 命令都将使用此变量。它更安全,因为 rsync 用户不是系统用户。您必须配置 rsync 服务器,但这非常简单。您可以通过在 rsync 配置中使用主机允许指令来保护 rsync 共享。
| 归档时间: |
|
| 查看次数: |
2029 次 |
| 最近记录: |