简体   繁体   English

在没有登录的情况下使用ssh-agent

[英]using ssh-agent without login

We would like to use ssh-agent to automatically connect to many machines through ssh, using a dedicated user on a ubuntu machine (12.04); 我们想使用ssh-agent通过ssh自动连接到许多机器,使用ubuntu机器上的专用用户(12.04); the problem is that since we have generated this user through a script 问题是因为我们已经通过脚本生成了这个用户

useradd -m -s /bin/bash USER

and we don't login to that user, the ssh-agent is not running and any attempt to use ssh without providing a password (we use python and paramiko) fails saying 我们没有登录到该用户,ssh-agent没有运行,任何尝试使用ssh而不提供密码(我们使用python和paramiko)都说不通

no autentication methods available

we have done some research, and found out that many people would start ssh-agent with this command-line 我们做了一些研究,发现许多人会用这个命令行启动ssh-agent

eval "ssh-agent"

but this won't work for us (especially when the above command is executed through python). 但这对我们不起作用(特别是当通过python执行上述命令时)。

The only way to make it work is to login to that user (through ssh for instance) and type the above comand, which make our automated approach not so automated: is there a way to make ssh-agent start at startup without the need to login to the dedicated user? 使其工作的唯一方法是登录该用户(例如通过ssh)并键入上述命令,这使我们的自动化方法不那么自动化:有没有办法让ssh-agent在启动时启动而无需登录专用用户?

I think this question will be better answered in the Server Fault website. 我认为在Server Fault网站上可以更好地回答这个问题。

But, here is an idea. 但是,这是一个想法。

Create an init script on all the pcs, such that when the pc starts, it logs in as the user and starts ssh-agent and logs out. 在所有PC上创建一个init脚本,这样当pc启动时,它会以用户身份登录并启动ssh-agent并注销。 Set the init script run level to start whenever the pc starts in normal/multi-user mode. 设置init脚本运行级别,以便在pc以普通/多用户模式启动时启动。

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

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