Solved Backup using SFTP with SSH Key

Status
Not open for further replies.

fgc92210

Customer
Advanced Certified
Joined
Oct 28, 2020
Messages
185
Reaction score
29
So I had it working a while back and for the heck of me can't get it to work anymore.
My goal is to use SFTP Backup using a SSH key in order to test 3CX Redundancy (so backup location needs to be shared by the 2 systems).

I have a linux server, with a user "3cx" setup with its ssh key.
This user can ssh to the public IP of its own server without password correctly.

In 3CX for the backup, I have
SFTP as file transfer,
Path is sftp://ip_of_server/home/3cx/backup/ (also tried sftp://3cx@ip_of_server/home/3cx/backup/ )
Username: 3cx (tried without username)
password: nothing
SSH Key: private key from the 3cx user

The checksum of the id.rsa file I am trying to upload under SSH Key is the same checksum as the id.rsa key for the 3cx on the local backup server

Still getting "cannot connect to sftp - SSH File Transfer"
Any hint?
 
Hi @ChrisC_3CX

I will do it this week.
On the other hand, I went on my linux box and ran SSHD in foreground in debug mode to see if 3CX even tries an attempt to connect, and I had nothing coming in. So the issue/blockage is definitely on the 3cx side. I will send you my private key in your PM if you don't mind so you can ask R&D if it has the right format, or maybe they can tweak something on their end? Thank you
 
As per our PM, I've tested the private key you said and it indeed doesn't work. I've converted it as mentioned in my previous reply and also used the full path to the backup folder and everything seems to work fine.
 
Chris
I don't get it... In your august 30th post, you mentioned you generated a key through ssh-keygen and it worked.
This key is already an OpenSSH Key. Does 3CX expect a specific version? Did you use any option on the command line?

From the linux man on ssh-keygen:
(...) ssh-keygen will by default write keys in an OpenSSH-specific format. (...)

There must be something in 3CX. Anyway 3CX can take whatever key instead of testing it?
From my traces, it looks like there is zero connection attempt when I upload the key and hit OK.
I understand 3CX wants to check things first, but whatever it is checking here is not working..

I even copied my private key in my 3CX and using it, I can connect to my backup server:

Code:
frank@iMac:~/Downloads> scp 3cx_private.key root@3cx:~/
3cx_private.key                                                                                                                                                             100% 1831   109.2KB/s   00:00   
frank@iMac:~/Downloads> ssh root@3cx
Linux 3cx.gadotek.com 4.19.0-12-cloud-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Sep  3 12:05:54 2021 from 71.58.47.10

root@3cx:~> ssh [email protected] -i ./3cx_private.key
3cx@zeus:~>

So the 3CX Debian takes it correctly.
Issue is within 3CX itself.
 
I don't get it... In your august 30th post, you mentioned you generated a key through ssh-keygen and it worked.
That's right, I had only used the commands mentioned in the guide. The only thing I did extra was to manually import the public key on the OS level.

In any case, I think it has been proven more than once during the progress of this thread that this is not a 3CX issue as you yourself have confirmed that the keys I provided you with worked and I have also managed to get your own keys to work after following the provided guide.

That said, I will proceed with marking this as resolved.
 
UPDATE:

After investigation it has been determined that the ssh-keygen command mentioned in our guide may not generate the necessary key format depending on what version OpenSSH is running. A minor modification will be made to the guide to accommodate for this.

Note: Converting the keys using the mentioned methods should still work regardless.

Thank you @fgc92210 for bringing this to our attention.
 
Status
Not open for further replies.

Forum statistics

Threads
111,974
Messages
590,081
Members
164,899
Latest member
mazet