带密码的shell脚本中的SSH [英] SSH in shell script with password

查看:62
本文介绍了带密码的shell脚本中的SSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个像这样的shell脚本

I want to write one shell script like

command1    
ssh vivek@remotehost 
    fire command on remote host

现在我在 pass.txt 中有密码.但是当我用文件更改标准输入时.它不是从文件中读取密码.

Now I have password in pass.txt . But when I change stdin with file. It is not reading password from file.

script.sh < password.txt 

它提示输入密码而不是从文件中读取密码.我做错了什么?

It is prompting for the password in place of reading password from the file. What I am doing wrong ?

第二个问题是 shell 脚本不显示命令被触发.有没有办法,我可以从中显示已触发的命令?

Second problem is that shell script don't shows the command fired. Is there a way , I can show fired command from it ?

注意:我在远程系统上没有基于密钥的访问.我只能使用基于密码的 ssh 登录.

Note : I don't have key based access on remote system. I can only use password based login for ssh.

推荐答案

您可以使用 ssh-agent 或 expect(编程语言)来执行此操作.

You can use ssh-agent or expect (the programing language) to do this.

这篇关于带密码的shell脚本中的SSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆