0
我想暂时将一个自定义密钥添加到ssh-agent
,执行几条命令并忘记它。以下ssh-agent子进程中的几个命令
手册页指出:
的ssh-agent [-c | -s] [-d] [-a bind_address] [-t life] [command [arg ...]]
如果给出命令行,这将作为代理的子进程执行。当命令死亡时,代理人也是如此。
试验表明,它确实是一个命令工作得很好:
# ssh-agent ssh-add user_rsa_key
Identity added: user_rsa_key (user_rsa_key)
但不可用多个命令:
# ssh-agent { ssh-add user_rsa_key; ssh-add -l; }
-bash: syntax error near unexpected token `}'
# ssh-agent $(ssh-add user_rsa_key; ssh-add -l)
Could not open a connection to your authentication agent.
Could not open a connection to your authentication agent.
SSH_AUTH_SOCK=/tmp/ssh-UQYDpH5Mopk3/agent.25436; export SSH_AUTH_SOCK;
SSH_AGENT_PID=25437; export SSH_AGENT_PID;
echo Agent pid 25437;
有没有办法?
攻击可能是使用'-t'选项指定一个明确的生命周期,尽管这样可能会导致密钥过期失效或保持时间超过必要的时间。 – chepner