我试图在远程服务器上运行一个脚本,无论是密码凭据或. pem密钥访问,我得到错误,无论我找到了什么解决方案等。
bash脚本内容:
#!/bin/bash
sudo fdisk -l
ssh -T -i "~/.ssh/keys/key.pem" ubuntu@host "sudo bash <(wget -qO- http://host.com/do.sh)"
Error: bash: /dev/fd/63: No such file or director
ssh user@host.com 'echo "password" | sudo bash <(wget -qO- http://www.host.io/do.sh)'
Error: sudo: a password is required
ssh -t user@host.com "echo password | sudo fdisk -l"
Works but still gives me the password propmt
echo -t pass | ssh user@host "sudo bash <(wget -qO- http://host.com/do.sh)"
echo -tt pass | ssh user@host "sudo bash <(wget -qO- http://host.com/do.sh)"
Error: bash: /dev/fd/63: No such file or directory
// And I also get the password prompt
echo -tT pass | ssh user@host "sudo bash <(wget -qO- http://host.com/do.sh)"
Error: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
// And I also get the password prompt
// This works but I still get the password propmt
ssh user@host 'echo "password" | sudo -S sudo fdisk -l'
这些是从其他地方得到的假设解的不同变体。
我想做的是:
1.从远程服务器上的URL运行脚本,同时将密码回显到cmd,这样我就不会得到提示来手动输入密码。
1.为了能够使用. pem密钥变体执行上述相同的操作
1条答案
按热度按时间lxkprmvk1#
有关除第一个命令以外的命令的说明,如果
ssh
要求交互式操作,则无法执行stdin-将密码重定向到ssh。ssh
仅允许手动键入密码。您的第一个错误指出bash无法读取文件描述符。因此,ssh通过
~/.ssh/keys/key.pem
可以工作。要动态运行shell命令,