dorel14 / 3CX-Cdr-Tcp-Server

GNU General Public License v3.0
4 stars 3 forks source link

issues with SCP - Permission denied /home/appuser/cdrflies/cdr-2405085802.269311.log #27

Closed MrGlenn-tech closed 1 month ago

MrGlenn-tech commented 1 month ago

Hi,

Everything starts up now but nothing get´s fetched when using SCP. this is the log.

Seems like somehing to do with permission on the docker if im not wrong? am i doing something wrong here?

== End of kex handshake === Resetting outbound seqno after NEWKEYS due to strict mode kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256> Switch to new keys ... Resetting inbound seqno after NEWKEYS due to strict mode Adding ssh-ed25519 host key for [172.17.17.61]:22: b'0360d4ac77fd471a8f89f2ea4084c50a' Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com,ssh-dss,ssh-rsa,rsa-sha2-256,rsa-sha2-512', 'publickey-hostbound@openssh.com': b'0'} userauth is OK Authentication (password) successful! /var/lib/3cxpbx/Instance1/Data/Logs/CDRLogs/ [chan 0] Max packet in: 32768 bytes Received global request "hostkeys-00@openssh.com" Rejecting "hostkeys-00@openssh.com" global request from server. [chan 0] Max packet out: 32768 bytes Secsh channel 0 opened. [chan 0] Sesch channel 0 request ok [chan 0] Opened sftp connection (server version 3) [chan 0] stat(b'/var/lib/3cxpbx/Instance1/Data/Logs/CDRLogs/') [chan 0] normalize(b'/var/lib/3cxpbx/Instance1/Data/Logs/CDRLogs/') [chan 0] listdir(b'/var/lib/3cxpbx/Instance1/Data/Logs/CDRLogs') [chan 1] Max packet in: 32768 bytes [chan 1] Max packet out: 32768 bytes Secsh channel 1 opened. fichier cdr-240508085802.269311.log [chan 1] Sesch channel 1 request ok [chan 1] EOF sent (1) Traceback (most recent call last): File "/home/appuser/app/srv/runserver.py", line 51, in <module> scpc.monitor(os.environ.get('SCP_3CX_SRVDIR'), File "/home/appuser/app/myhelpers/scpclient.py", line 30, in monitor scp.get(remote_path=scpfilename, File "/home/appuser/venv/lib/python3.12/site-packages/scp.py", line 281, in get self._recv_all() File "/home/appuser/venv/lib/python3.12/site-packages/scp.py", line 436, in _recv_all command[code](msg[1:]) File "/home/appuser/venv/lib/python3.12/site-packages/scp.py", line 475, in _recv_file file_hdl = open(path, 'wb') ^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied: '/home/appuser/cdrfiles/cdr-240508085802.269311.log' [chan 0] EOF sent (0) Dropping user packet because connection is dead.

dorel14 commented 1 month ago

Hello Thx for the beer

You can test lastest , i think it will fix this

MrGlenn-tech commented 1 month ago

No worries you deserve them and more!

I just deleted the old docker containers and did a new git clone but get this error now when trying docker-compose up -d

ERROR: Named volume "cdr_datas:/home/appuser/cdrfiles:rw" is used in service "3cxcdrserver" but no declaration was found in the volumes section.

dorel14 commented 1 month ago

I've push what docker compose file need

MrGlenn-tech commented 1 month ago

Tested it now with a new git clone.

Almost the samme error message i set the folder in the .env file and this is the error now

ERROR: Named volume "LOCAL_CDR_FOLDER_ARCHIVE=/home/administrator/3CX-Cdr-Tcp-Server/old:/home/appuser/cdrfiles/cdrfiles_archives:rw" is used in service "3cxcdrserver" but no declaration was found in the volumes section.

dorel14 commented 1 month ago

Really strange my docker compose don't show this kind of logs

I will re test this evening

dorel14 commented 1 month ago

Tested with my server and no message, it runs

MrGlenn-tech commented 1 month ago

Tested with my server and no message, it runs

Strange, i did a roll back on the test server did a fresh install of docker and docker-compose and did a git clone.

do you mind sharing your .env file so i can test with that to see if it starts, you can just remove your passwords/personal info

dorel14 commented 1 month ago

Debian GNU/Linux 12 (bookworm) Docker Version: 20.10.24+dfsg1 Docker Compose version v2.24.5

#TZ informations
TZ=Europe/Paris

#Locales informations
LOCALE_LANGUAGE =fr_FR

# Db informations
POSTGRES_USER=postgres
POSTGRES_PASSWORD=_password_
POSTGRES_SERVER=db
POSTGRES_PORT=5432
POSTGRES_DB= cdr3cxdb

#PG Admin informations
PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org
PGADMIN_DEFAULT_PASSWORD=_password_

#Grafane informations
GF_SECURITY_ADMIN_PASSWORD=_password_

#Prefered server type (FTP - SFTP - TCP) 
# If FTP , you need to set informations in #3cx FTP informations
# If SFTP , you need to set informations in #3cx FTP informations
# If TCP , you need to set informations in #3cx TCP Server port
# If SCP , you need to set informations in #3cx SCP informations

SERVER_TYPE=SCP

#3cx FTP informations
FTP_3CX_HOST=
FTP_3CX_PORT=21
FTP_3CX_LOGIN=
FTP_3CX_PASSWORD=

FTP_3CX_SRVDIR='_pathonftp_'

#If you set a private key for SFTP client
FTP_3CX_PRIVATE_KEY_PATH = 
FTP_3CX_PRIVATE_KEY_PASSWORD=

#Set the interval in which ftp / scp client will look at the server for new files
FTP_3CX_INTERVAL= 60

#Set to ARCHIVE if you want the files on FTP SERVER to be renamed with à .old
#Set to DELETE if you want to delete files on FTP SERVER
FTP_3CX_ARCHIVE_OR_DELETE = ARCHIVE 

#3cx SCP informations
SCP_3CX_HOST=_ip_
SCP_3CX_PORT=22
SCP_3CX_LOGIN=_login_
SCP_3CX_PASSWORD=_password_
SCP_3CX_SRVDIR='_pathon3cxserver_'
SCP_3CX_INTERVAL=60

#Set to ARCHIVE if you want the files on FTP SERVER to be renamed with à .old
#Set to DELETE if you want to delete files on FTP SERVER
SCP_3CX_ARCHIVE_OR_DELETE = ARCHIVE 

#CDR folder on local server where to archives CDR files 
LOCAL_CDR_FOLDER_ARCHIVE='_pathOndockerserverforarchiving_'

#3CX CDR file extension
3CX_FILEEXT=*.csv

#3cx TCP Server port
SERVER_PORT=5000

#Api URL
API_URL=http://webapi:8000
MrGlenn-tech commented 1 month ago

So i tested with your .env but got the same results as i had before.

But when i tested to set LOCAL_CDR_FOLDER_ARCHIVE='/' it worked and the docker started :) i then changed the folder to /home/administrator/3CX-Cdr-Tcp-Server/old and started docker again and it worked a bit weird but it works.

But i see that 3cx-cdr-tcp-server_3cxcdrserver keeps restarting and when i check the logs this is the error message i get.

Starting new HTTP connection (1): webapi:8000 http://webapi:8000 "GET /api/v1/cdr/historyid/Call%20275467 HTTP/1.1" 404 29 Starting new HTTP connection (1): webapi:8000 http://webapi:8000 "GET /api/v1/cdrdetails/historyid/Call%20275467 HTTP/1.1" 404 29 404 404 Starting new HTTP connection (1): webapi:8000 http://webapi:8000 "POST /api/v1/cdr HTTP/1.1" 422 123 422 b'{"detail":[{"type":"string_type","loc":["body","from_dispname"],"msg":"Input should be a valid string","input":730XXXXX}]}' cdr detail existant 422 cdr detail existant Line1: Call 275467,918cba998f010000_13428,00:00:59,2024/05/21 05:58:10,2024/05/21 05:58:18,2024/05/21 05:59:17,TerminatedByDst,073XXXX,Ext.80025,10020,80025,80025,ReplacedDst,Ext.10007,10007,,,,,Chain: 07XXXXXXX;Ext.80025;Ext.10007;,Line,Queue,Extension,073XXXXX,Säkra Larm (LC),Niklas Wilhelmsson, Line2: cdr-240521055810.275467.log [chan 1] EOF sent (1) Traceback (most recent call last): File "/home/appuser/app/srv/runserver.py", line 51, in <module> scpc.monitor(os.environ.get('SCP_3CX_SRVDIR'), File "/home/appuser/app/myhelpers/scpclient.py", line 38, in monitor csv_files_read(localfolder, archivefolder) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/appuser/app/myhelpers/traitement_fichier.py", line 54, in csv_files_read files_move(f, archivefolder) File "/home/appuser/app/myhelpers/traitement_fichier.py", line 23, in files_move os.mkdir(savefolderd) PermissionError: [Errno 13] Permission denied: '/home/appuser/cdrfiles/cdrfiles_archives//2024/'

Any suggestions?

dorel14 commented 1 month ago

There are 2 different problems : 1 with the cdr file sending a call already in dB , if you can share it i will débug

2- there is a read write rights problem with the folder you set as LOCAL_CDR_FOLDER_ARCHIVE=

Are you sure the user you use to run docker have thé right to read/write on this folder ?

To permit end user to see archives, the volume the container is mounted and shared with local folder

dorel14 commented 1 month ago

Hello , i have made some improvements in permissions checking
it's in latest master

MrGlenn-tech commented 1 month ago

So i did a new git clone,

But now as soon as i do a docker-compose up the server stops responding to ping Creating network "3cx-cdr-tcp-server_default with the default driver then everything stops i can log in to the server terminal from the host where it seems "to work" but i cant confirme it.

dorel14 commented 1 month ago

Happy to ear it start without problem

Normally from your host , if you run ifconfig you will get the containers ip

in my testing environment , for example if i test dockerhost_ip:3000 in chrome i get grafana and dockerhost_ip:5555 i get pgAdmin

docker ps |grep 3cx

running this command will show you the container that ar running

docker log + cointainer nam or id 

Running this one will show you the logs