Hi! this is a quick tip connect to SFTP server using a SSH key and password authentication.
Recently I’ve received a file created with Putty Key Generator «file.ppk», in order to establish the connection from terminal I had to use the private key and password to comply with the authentication method.
So, I had to extract the private key as shown as follow:
1. Open Putty Key Generator, select menu Conversions > Import key and load the ppk file
2. Select Conversions > Export OpenSSH key, you can save it with or without passphrase
3. Grant the permissions at the created file only for your user:
# Windows
icacls filename /inheritance:r /grant username:F
# Unix
chmod 700 filename
4. Open the terminal and go to the folder where you saved the key, then execute the next command:
sftp -oHostKeyAlgorithms=+ssh-rsa -i <key> <username>@<server ip>
Complete the pasword prompt (and the passphrase if you setted one) to establish the connection, the output must show something like this:
$ sftp -oHostKeyAlgorithms=+ssh-rsa -i id_dummy_rsa dummyuser@111.222.33.321 (dummyuser@111.222.33.321) Enter password: Connected to 111.222.33.321. sftp>
And thats it!
bye! =D