自动化SSH不使用公共密钥认证或预期(1) [英] Automate SSH without using public key authentication or expect(1)

查看:167
本文介绍了自动化SSH不使用公共密钥认证或预期(1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过一个密码来自动SSH协议。我想自动ssh到服务器的使用公钥认证或期望的脚本,通过某种方式让ssh来阅读从标准输入或文件的密码。

Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server without using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file.

它是这个样子的原因是,我想我的备份文件,使用运行作为cron作业的rsync / SSH服务器。该服务器后装入我的主目录的 它验证了我,因此,使用公钥验证不起作用,因为的〜/ .ssh不适后才登录成功。期待(1)是不可能的,因为我想运行它作为一个cron作业,而且由于cron作业没有终端下运行预期的组合/ SSH是行不通的。我没有到该服务器的root访问权限,这将是很难得到管理员做任何改变的东西在那里工作的方式。

The reason it has to be that way is that I would like to backup my files to a server using rsync/ssh running as a cron job. This server mounts my home directory after it authenticates me, so using public key authentication does not work since ~/.ssh isn't available until after the login is successful. expect(1) is out of the question because I would like to run it as a cron job, and since cron jobs don't run under a terminal the combination of expect/ssh just doesn't work. I do not have root access to that server, and it would be difficult to get the admins to make any changes to the way things work there.

推荐答案

使用 sshpass

例如,当密码是在的password.txt 文件:

For example, when password is in password.txt file:

sshpass -fpassword.txt ssh username@hostname

(从答案带到类似的问题

这篇关于自动化SSH不使用公共密钥认证或预期(1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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