I'm attempting to communicate between two Solaris servers via Paramiko. I can't use my private key for security reasons so am attempting to use id_rsa.pub. Originally I tried this:
ssh.connect(hostname=host, username=user, key_filename=path-to-key)
...where ssh is an SSHClient object. Eventually my googling led me to believe that connect really expects a private key, not public, so I tried the solution here. The difference with this one is that it uses transport.auth_publickey to do the authentication, which I hoped would get me around any formatting hangups. Here's the significant portion:
try:
ki = paramiko.RSAKey.from_private_key_file(filename=key_file)
except Exception, e:
print 'Failed loading {0}. {1}'.format(key_file, e)
return
I've checked my key_file and it is definitely pointing at my id_rsa.pub file, which is in OpenSSH format (I think; it starts with ssh-rsa and ends with user@host). Still, I consistently hit the exception above, with e being, "not a valid RSA private key file". Looking into the code, the closest error I can find to this is in the decoding step from BER. I don't really know anything about BER or OpenSSH, but google seems to think they're the same thing, or at least compatible.
There are plenty of answers to similar questions here, but nothing that indicates why my solution doesn't work. I'm not reading some strange format, I'm not confusing the key file with the key itself, etc.
Anyone have success using id_rsa.pub or an equivalent with Paramiko? Preferably on *nix. I'm also open to, "Hey, idiot! Why are you using Paramiko when there's something so much easier!" ...so long as the criticism is constructive.