누군가가 GitHub 용으로 올바르게 설정된 SSH 키를 가지고 있는지 프로그래밍 방식으로 확인하고 싶습니다. Ruby에서 `ssh -T [email protected]`
을 사용할 수 있음을 이해합니다. 그러나, 나는 변수에 ssh 출력을 유지하고 싶습니다.ssh 명령의 출력을 얻으려면 어떻게해야합니까?
내 현재 코드는 다음과 같습니다
github_response = `ssh -T [email protected]`
unless github_response.start_with?('Hi')
puts 'Please set up your GitHub ssh keys'
end
`ssh -T [email protected]`
는 ("안녕"로 시작하는) 응답을 출력합니다. 그러나 github_response
변수는 nil
입니다.
`ssh -T [email protected]`
의 출력을 github_response
에 어떻게 지정할 수 있습니까?