Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 241
Dishant Avatar asked Nov 05 '22 05:11

Dishant


1 Answers

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.

like image 112
déo Avatar answered Nov 09 '22 05:11

déo