Importing OpenSSH RSA Public / Private Key Pair into Apple's Keychain Access - iphone

As stated in the title, I would like to import a key pair into Keychain Access.
What I have done:
Obtaining an RSA public / private key pair by using OpenSSH
What I am going to do:
Importing the key pair into the "login" keychain of Keychain Access
Creating a CSR with OpenSSL
Send the CSR to Apple for obtaining a developer certificate
Any suggestions are welcomed.

Found the answer by myself:
Open Terminal.app:
$ security import developer_rsa_key -k login.keychain -t priv -f openssh2
1 key imported.
$ security import developer_rsa_key.pub -k login.keychain -t pub -f openssh2
1 key imported.

Related

GitHub : import SSH i cant import ssh key in my github account

when i want to import my ssh key in github i have This Erorr "Key is invalid. You must supply a key in OpenSSH public key format"
Try again with:
ssh -P "" -t rsa -f ~/.ssh/github
cat ~/.ssh/github.pub
Copy the public key content in your GitHub SSH setting page: this one should work.
One starting with SHA256:... looks like a key fingerprint, not an actual public key.

How to add a passphrase for ssh key after its been created?

Is generating a new one necessary, or is there a way to go back and add a passphrase?
I have generated an ssh key, but would like to go back and add a passphrase. I haven't linked it to my github yet. Is there any way to do this?
As explained here, you can add a passphrase to an existing private key with:
cd ~/.ssh
ssh-keygen -o -p -f keyfile
But you can also link that to GitHub immediately: adding a passphrase (encrypting the private key) does not change the public key you would register to your GitHub profile.
The public key will remain the same, before and after you add a passphrase to your local private key.

Which private key using for CSR generated by TPM2?

I'm following guidline to generate CSR: https://github.com/irtimmer/tpm2-pk11/wiki
After get certificate which signed by server side, in my case, I have to use private key used for CSR generation to handshake with SSL connection with server. I tried to convert key.priv using base64 command but failed.
And my questions:
1) Can I use private key "key.priv" when created private key in TPM. If not which private key will be accepted?
tpm2_create -c po.ctx -g sha256 -G rsa -u key.pub -r key.priv
2) What are key.pub and key.priv used for?
Thank you very much.

How do I know which ssh key is used in my github account?

When I go to the SSH keys page in my GitHub account, I see a key whose identity starts with "c5:42:08:9d:39:22..."
On my computer, in the ".ssh" folder, I have several files that look like public SSH keys, but none of them contains a string similar to the above. For example, one
of the files "id_rsa.pub" contains a string that starts with "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA..." there are other similar files that probably represent different keys.
How can I identify which of the files, if any, represents the actual key that is in my github account?
"c5:42:08:9d:39:22..." isn't the key, but rather the key's fingerprint. You can see your key's fingerprint using ssh-keygen:
ssh-keygen -lf ~/.ssh/id_rsa
Where
-l means we want to see the key's fingerprint
-f ~/.ssh/id_rsa is a path to the key whose fingerprint we want to see
On older versions of OpenSSH, you may need to also specify that you want the SHA256 fingerprint rather than another hash like MD5, since SHA256 is what GitHub shows in its web interface:
ssh-keygen -lf ~/.ssh/id_rsa -E sha256
You should get the same fingerprint from the public part as from the private part of the keypair.

connecting to server through SSH using public key

I am working on one iPhone application on which we need to use SSH integration. I have demo that can connect server with password, but i can't get how to connect that using public key.
I can connect it via MAC terminal using below command.
ssh -i (KeyFilePath) username#(domainname or IP)
But unfortunately, I can't connect using Xcode.
Thanks,
You may want to consider first adding the private key (or keys) to the authentication agent. From that point and on, all ssh commands will re-use the cached key:
# Add a new key to the authentication agent
$ ssh-add <path to private key>
# List current keys
$ ssh-add -l
# Delete all loaded keys
$ ssh-add -D
# Add a new key and store the passphrase in your keychain
$ ssh-add -K <path to private key1>
$ ssh-add -K <path to private key2>
# After storing the private keys passphrase in the keychain,
# you can load them all, at any time
$ ssh-add -k
When the authentication agent has a private key loaded, you should be able to use Xcode to connect to (domainname or IP) with no problems.