简体   繁体   English

如何自动登录SSH服务器并运行一些命令来修改文件

[英]How to auto login ssh server and run some command to modify a file

Here is the limitations: 这里是限制:

  1. No public key file uploaded to server (since this may be run at different target machine), this is just for an automatic testing program, so security is not a concern. 没有公钥文件上载到服务器(因为它可能在不同的目标计算机上运行),这仅用于自动测试程序,因此安全性不是问题。
  2. It's automatically program run background, so no user input. 它是程序自动在后台运行,因此无需用户输入。
  3. I do not want to use "expect" which require user to install. 我不想使用需要用户安装的“期望”。
  4. I have know the root user's password. 我知道root用户的密码。

So I wonder is that a lightweight expect tool or a ssh library I can easily use to do such work. 所以我想知道我可以轻松地使用轻量级的Expect工具或ssh库来完成此类工作。

libssh http://www.libssh.org/ can help for a C project. libssh http://www.libssh.org/可以为C项目提供帮助。 Using Perl, there is a module which can be used: Net::SSH (I use it for +/- the same kind of purposes) 使用Perl,有一个可以使用的模块:Net :: SSH(我将其用于+/-相同目的)

唯一正确的安全方法是使用导出的SSH公钥文件,每个客户端和每台服务器均已通过验证,否则,阻止哈巴巴迪先生利用该系统的措施是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM