linux vm 登录使用 Shell 脚本

标签 linux bash ssh

我们有云虚拟机,我们可以通过 WinSCP 和 Putty 使用 pem 和 ppk 文件登录。我打算编写一个 shell 脚本程序来登录这些机器。我尝试了类似的方法但没有成功。

ssh -i ~/ec2.pem ubuntu@12.34.56.78

Permissions 0664 for '/home/cloud-user/house_keeping/conf/ecp.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: /home/cloud-user/house_keeping/conf/ecp.pem`enter code here`
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

最佳答案

问题是

Permissions 0664 for '/home/cloud-user/house_keeping/conf/ecp.pem' are too open.

ssh 的手册页解释了私钥上的权限:

These files contain sensitive data and should be readable by the user but not accessible by others (read/write/execute).

所以你应该使用 0600 更改权限

chmod 600 ~/ec2.pem

关于linux vm 登录使用 Shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43132641/

相关文章:

linux - Bash "ps"并行进程并检查它们何时完成

macos - Git 停止提示输入密码

bash - While 循环在 Bash 中的第一行之后停止读取

linux - 32 位 Linux 程序的整个运行时库树是否需要是 32 位的?

linux - 如何在 fedora 中安装 source rpm(src.rpm)?

php 使用 ssh 调用 bash 脚本

linux - 如何运行命令,该命令在后台执行另一个运行脚本的终端

linux - 在脚本中使用 ssh 执行 passwd 命令后没有返回

linux - 在 Bash 中,如何在文件的每一行之后添加一个字符串?

ubuntu - "Confirm user presence for key"使用 Yubikey 进行 SSH 连接时不显示消息