문제

When trying to clone a remote repo with Rugged, I keep getting the error Failed to authenticate SSH session: Unable to open public key file

I add my ssh credentials fine, but when I come to doing the clone the above error occurs.

cred = Rugged::Credentials::SshKey.new({username: 'gabriel403', publickey: publickey, privatekey: privatekey})
Rails.logger.debug cred

Where publickey and privatekey are string holding the keys.

repo = Rugged::Repository.clone_at('git@github.com:gabriel403/dotfiles.git', '/tmp/dotfiles', {credentials: cred})
Rails.logger.debug repo
도움이 되었습니까?

해결책

:publickey and :privatekey need to be expanded paths to the public and private key file locations on the disk. If your application works with the key data directly, you could try writing the data to tempfiles and passing in the paths to those files.

Just make sure to understand possible security risks when doing that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top