# Trouble publishing via SFTP with public/private key authentication

**URL:** <https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938>\
**Category:** RapidWeaver Classic\
**Created:** [May 24, 2019, 1:00pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938 "2019-05-24T13:00:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![differentdan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/differentdan/32/33530_2.png) [@differentdan](https://forums.realmacsoftware.com/u/differentdan)\
**Post date:** [May 24, 2019, 1:00pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/1 "2019-05-24T13:00:26Z")

</div>

Hi everyone.

Anybody have any suggestions on what might be the issue, or has anyone experienced anything similar?

I’m having trouble making a connection to my server using RapidWeaver’s 8.2 SFTP publishing setting (but it was also happening in 8.1.7). I use public/private key authentication to connect, and it works fine when I connect through my Terminal (can establish an SFTP connection without any kind of issue), but when I try to test the connection in the RapidWeaver publishing settings, I get the below error:

 ![51%20PM](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/2X/5/5f456cd4ba291a86419670110dfbff7226416527.png)

I enabled the Publishing logging, and below is the output of that:

2019-05-24 xx:xx:xx.xxx RapidWeaver 8[5337:502425] [0] Trying xxx.xx.xx.xx…  
[0] TCP\_NODELAY set  
[0] Connected to xxx.xx.xx.xx (xxx.xx.xx.xx) port 22 (#0)  
[0] SSH MD5 fingerprint: xxxxxxxxxxxxxxxxxxxxxxx  
[0] SSH authentication methods available: publickey  
[0] Using SSH private key file ‘/Users/xxxxxxxxxxxxx/.ssh/id\_rsa’  
[0] **SSH public key authentication failed: Unable to extract public key from private key file: Wrong passphrase or invalid/unrecognized private key file format**  
[0] Authentication failure  
[0] Closing connection 0

I don’t understand why the error says “_wrong passphrase or invalid/unrecognized private key file format_” when it works just fine when connecting from Terminal:

 ![41%20PM](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/2X/d/dd5cae92faaab63928260ab57a6e2b00e94fead6.png)

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [May 25, 2019, 12:55pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/2 "2019-05-25T12:55:59Z")

</div>

Have you tried connecting with another ftp client like transmit or FileZilla?

---

<div class="post-metadata">

**Author:** ![LaPan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/lapan/32/92_2.png) [@LaPan](https://forums.realmacsoftware.com/u/LaPan)\
**Post date:** [May 25, 2019, 2:55pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/3 "2019-05-25T14:55:17Z")

</div>

It’s a longshot but make sure you don’t have any leading/trailing spaces in your login/password. It’s better to type in than copy/paste (for now).

---

<div class="post-metadata">

**Author:** ![differentdan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/differentdan/32/33530_2.png) [@differentdan](https://forums.realmacsoftware.com/u/differentdan)\
**Post date:** [May 26, 2019, 5:16am UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/4 "2019-05-26T05:16:05Z")

</div>

That works fine, but I was hoping to use RapidWeaver’s built in publishing feature. 🙂

---

<div class="post-metadata">

**Author:** ![differentdan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/differentdan/32/33530_2.png) [@differentdan](https://forums.realmacsoftware.com/u/differentdan)\
**Post date:** [May 26, 2019, 5:18am UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/5 "2019-05-26T05:18:37Z")

</div>

I’m not using a password, I’m using public/private key authentication. The password field is left blank in RapidWeaver’s publishing settings, only the passphrase field is completed.

RapidWeaver is saying " **Wrong passphrase or invalid/unrecognized private key file format**" which doesn’t make sense considering I can connect through SFTP via Terminal, or any other SFTP client.

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [May 27, 2019, 1:01pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/6 "2019-05-27T13:01:21Z")

</div>

Is there a reason why you are using the _passphrase_ option with SFTP?

I’ve been using SSH and SFTP for years at multiple clients but can’t remember the last time I saw a passphrase being used.

The passphrase only provides additional security on the client side (your mac In this instance) by encrypting the private key stored there(`~/.ssh/id_rsa`).

Don’t know if this is causing the problem but looking at the log entry you posted(assuming the parts you x’ed out match) I would try regenerating the public and private keys without a passphrase and see if that connects.

Passphrases were mainly designed for keys belonging to interactive users like a terminal user. For automatic processes like an ftp client or RapidWeaver the passphrase is stored so it doesn’t make sense to use one since anyone that has access to these apps has access to the passphrase.

Per [Passphrase Explained: What is a Good Passphrase?](https://www.ssh.com/ssh/passphrase)

> More than 90% of all SSH keys in most large enterprises are without a passphrase.

---

<div class="post-metadata">

**Author:** ![differentdan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/differentdan/32/33530_2.png) [@differentdan](https://forums.realmacsoftware.com/u/differentdan)\
**Post date:** [May 28, 2019, 10:43am UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/7 "2019-05-28T10:43:38Z")

</div>

> Is there a reason why you are using the _passphrase_ option with SFTP?

Yeah, because I always protect my public/private keys with a passphrase. I don’t feel I should have to not use a passphrase for the connection in RapidWeaver to work, especially since it provides the option for public/private key authentication to be used.

 ![31%20PM](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/2X/8/8d04615f1bb63702ffa27c09097c9cb3acfdbfaa.png)

---

<div class="post-metadata">

**Author:** ![teefers](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/teefers/32/8173_2.png) [@teefers](https://forums.realmacsoftware.com/u/teefers)\
**Post date:** [May 28, 2019, 12:25pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/8 "2019-05-28T12:25:58Z")

</div>

I was suggesting that you “try” without the “passphrase” as an attempt to debug the publishing issue. **Still using public key authentication** , just no passphrase.

Since the passphrase is optional and only protects the private key stored on your Mac removing it shouldn’t create any security risk. I think it would be a good first step in the debugging process.

My only other suggestion would be to contact realmac support [support@realmacsoftware.com](mailto:support@realmacsoftware.com) with all the logs and information you have.

---

<div class="post-metadata">

**Author:** ![kappuchino](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/kappuchino/32/15298_2.png) [@kappuchino](https://forums.realmacsoftware.com/u/kappuchino)\
**Post date:** [June 13, 2019, 10:53pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/9 "2019-06-13T22:53:39Z")

</div>

I had the same problem. In my case, the error was caused the format of the private key (password protected or not does not matter.) - The default has changed from PEM to RFC4716.

Here is how to diagnose it:  
If your private key starts with -----BEGIN OPENSSH PRIVATE KEY----- _it is the wrong type_ (RFC4716), RW8 does not seem to read it (might be ssh-library related)  
If your private key starts with -----BEGIN RSA PRIVATE KEY----- _it might be the correct type_ (PEM). If the access still fails, enable verbose ssh logging.

Solution that worked for me:  
a) Best option is to generate a new key with the option -m PEM (also ssh-keygen -m PEM). I did that. Now it works.  
b) You can convert key with the option ssh-keygen -e -m PEM -f PathToKeyfile . It should work with already established keys, but that failed for unknown reasons for me and I decided not to persue.

Cheers!

---

<div class="post-metadata">

**Author:** ![joeworkman](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/joeworkman/32/23780_2.png) [@joeworkman](https://forums.realmacsoftware.com/u/joeworkman)\
**Post date:** [June 14, 2019, 6:21am UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/10 "2019-06-14T06:21:43Z")

</div>

Dude! No shit! Good job on that… I was working with @tpbradley and we could not figure this out… What do you think Tom?

---

<div class="post-metadata">

**Author:** ![kappuchino](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/kappuchino/32/15298_2.png) [@kappuchino](https://forums.realmacsoftware.com/u/kappuchino)\
**Post date:** [June 14, 2019, 2:42pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/11 "2019-06-14T14:42:15Z")

</div>

Thanks. I’m not particularly competent on ssh, but I had some issues with certificate types before 🙄 …

Can I suggest a way to fix this issue?

A “quick” fix might be a specific help text for the dialog choosing the certificate. Say “PEM” format and give a syntax example for the key generation.

Also, RW could mention the necessary key type in the error message. Right now, it points the mind to a “password” or file problem, but not to the encoding of the certificate.

A deeper handling of the issue could consist of checking the certificate type (rfc4716 see below vs pem - [https://tools.ietf.org/html/rfc1421](https://tools.ietf.org/html/rfc1421)) in the code. This can be done by using the formating rule for 4716 certs - see here [https://tools.ietf.org/html/rfc4716#section-3.5](https://tools.ietf.org/html/rfc4716#section-3.5) - five dashes (pem) vs. four (4716). This would enhance the error message.

Happy to have helped.

Cheers!

---

<div class="post-metadata">

**Author:** ![differentdan](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/differentdan/32/33530_2.png) [@differentdan](https://forums.realmacsoftware.com/u/differentdan)\
**Post date:** [June 15, 2019, 12:30pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/12 "2019-06-15T12:30:04Z")

</div>

![successful-connection](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/2X/6/6c12d9211e00f8cd27edf84108e1bd1b5cfd5920.png)

@kappuchino You sir, are awesome. 🕶

Just had a chance to test it and wanted to come back and say thank you so much for taking the time to write up the solution. I appreciate your time. Virtual beers for you! 🍻

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/system/32/25301_2.png) [@system](https://forums.realmacsoftware.com/u/system)\
**Post date:** [July 15, 2019, 10:30pm UTC](https://forums.realmacsoftware.com/t/trouble-publishing-via-sftp-with-public-private-key-authentication/26938/13 "2019-07-15T22:30:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
