简体   繁体   中英

Duplicity is arguing BackendException: ssh connection to my server:22 failed: not a valid OPENSSH private key file

Thanks to maybeg , I've managed to backup my data from home to an external server. (An amazon one) As i don't want to backup company datas to Amazon, i tried with an internal backup server.

I then used this command. (I have my own key)

docker run -d     --name volumerize     
-v /MyFolder/Keys/:/MyFolder/Keys/ 
-v jenkins_volume:/source:ro     
-v backup_volume:/backup     
-e 'VOLUMERIZE_SOURCE=/source' 
-e "VOLUMERIZE_TARGET=scp://myuser@mybackupserver/home/myuser/" 
-e 'VOLUMERIZE_DUPLICITY_OPTIONS=--ssh-options "-i /MyFolder/Keys/myuserkey"'  
-e 'PASSPHRASE="mypassphrase"' blacklabelops/volumerize

When using duplicity backup command, inside or outside the container, i have the following error

/usr/lib/python2.7/site-packages/paramiko/ecdsakey.py:200: DeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
  signature, ec.ECDSA(self.ecdsa_curve.hash_object())
BackendException: ssh connection to myuser@mybackupserver:22 failed: not a valid OPENSSH private key file

Strangely, inside or outside the volumerize container, the following is running properly.

ssh -i /MyFolder/Keys/myuserkey myuser@mybackupserver
key_load_public: invalid format
Enter passphrase for key '/MyFolder/Keys/myuser':
[myuser@mybackupserver ~]$

Editing backup file for example is giving me the following :

#!/bin/bash

set -o errexit

source /etc/volumerize/stopContainers
duplicity $@ --allow-source-mismatch --archive-dir=/volumerize-cache --ssh-options "-i /MyFolder/Keys/myuserkey"  /source scp://myuser@mybackupserver/home/myuser/
source /etc/volumerize/startContainers

I've tried to check env variables inside the container, please find below what i have : (Note that passphrase has been added as env variable as found here )

HOSTNAME=b68f0e1a2d45
TERM=xterm
BLACKLABELOPS_HOME=/var/blacklabelops
GOOGLE_DRIVE_CREDENTIAL_FILE=/credentials/googledrive.cred
VOLUMERIZE_HOME=/etc/volumerize
VOLUMERIZE_SOURCE=/source
DOCKERIZE_VERSION=v0.5.0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/volumerize
VOLUMERIZE_TARGET=scp://myuser@mybackupserver/home/myuser/
PWD=/etc/volumerize
VOLUMERIZE_DUPLICITY_OPTIONS=--ssh-options "-i /MyFolder/Keys/myuserkey"
VOLUMERIZE_CACHE=/volumerize-cache
GPG_TTY=/dev/console
SHLVL=1
HOME=/root
no_proxy=*.local, 169.254/16
GOOGLE_DRIVE_SETTINGS=/credentials/cred.file
PASSPHRASE="mypassphrase"
_=/usr/bin/env

Can someone point me in the right direction ?

Regards, pierre

Edit1 : I tried to compare both private key file (Amazon and Company) using openssl rsa -in yourkey.pem -check and both says

RSA key ok
writing RSA key
-----BEGIN RSA PRIVATE KEY-----
....
-----END RSA PRIVATE KEY-----

Edit2 : 1 . Had a look without any success at duplicity-backendexception

  1. For information, Paramiko version is 2.2.1

  2. Connection is successful using the following python script.

     import paramiko import StringIO f = open('/MyFolder/Keys/myuserkey','r') s = f.read() keyfile = StringIO.StringIO(s) mykey = paramiko.RSAKey.from_private_key(keyfile,password='mypassphrase') ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('mybackupserver',username='mouser',pkey=mykey) stdin, stdout, stderr = ssh.exec_command('uptime') stdout.readlines() 

    [u' 12:35:27 up 3 days, 1:42, 0 users, load average: 1.59, 3.10, 3.00\\n']

try the pexpect+scp:// backend (more on available ssh backends can be found in the duplicity manpage http://duplicity.nongnu.org/duplicity.1.html ).
it uses the command line ssh binaries. maybe the error is different or more detailed there?

the error on

ssh -i /MyFolder/Keys/myuserkey myuser@mybackupserver
key_load_public: invalid format

does not seem normal. try to provide the public key in the proper format or not at all.

..ede/duply.net

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM