There’s a recent change in the handling of SSH keys in MacOS Sierra that means you need to enter your passphrase each time a key is required. There’s an open Radar issue about it and it’s intended behaviour now.
You can work around it by implementing one of the solutions at the links below, I personally went with adding:
into my .zshrc file and that solved it for me (or .bash_rc if you use bash).
More information and solutions can be found at:
If you want to specify the keyfile used for an SFTP connection, you can use the following:
sftp -i /path/to/private/keyfile user@machine1:/path/to/file user@machine2:/path/to/file
A few tasks that I’ve been working on this weekend have needed public/private key pairs. The very useful phpseclib library provides the tools that you need to generate these within your application.
// Get a new RSA object and set the type, hash and comment
$rsa = new RSA;
// Actually generate the key, change 4096 for the desired number of bytes
$keys = $rsa->createKey(4096);
$keyPrivate = $keys["privatekey"];
$keyPublic = $keys["publickey"];
// Get the fingerprint for this key
$keyFingerprint = $rsa->getPublicKeyFingerprint();