2016-09-28 4 views
0

ssh-agent에 임시로 사용자 정의 키를 추가하고 싶지 않을 때 몇 가지 명령을 실행하고 잊어 버리십시오. 다음ssh-agent 서브 프로세스의 몇 가지 명령

맨 페이지 상태 :

SSH 에이전트 [-c | -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; 

거기를

테스트는 실제로 하나의 명령으로 잘 작동 것으로 나타났다?

+0

해킹은'-t' 옵션을 사용하여 명시 적 수명을 지정하는 것일 수 있지만, 너무 빨리 만료되거나 필요한 것보다 길게 유지 될 수 있습니다. – chepner

답변

1

랩 두 가지 (또는 그 이상)은 하나의 bash는 명령과 같은 내부 명령 :

ssh-agent bash -c "ssh-add user_rsa_key; ssh-add -l" 

(아마도 나 스크립트에 넣어).

관련 문제