感谢mayg,我设法将我的数据从家里备份到外部服务器。(亚马逊)因为我不想将公司数据备份到亚马逊,所以我尝试使用内部备份服务器。
然后我使用了这个命令。(我有自己的钥匙)
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
在容器内部或外部使用重复备份命令时,出现以下错误
/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
奇怪的是,在 volumerize 容器内部或外部,以下运行正常。
ssh -i /MyFolder/Keys/myuserkey myuser@mybackupserver
key_load_public: invalid format
Enter passphrase for key '/MyFolder/Keys/myuser':
[myuser@mybackupserver ~]$
例如,编辑备份文件给了我以下信息:
#!/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
我试图检查容器内的环境变量,请在下面找到我所拥有的:(请注意,密码已添加为 env 变量,如此处所示)
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
有人能指出我正确的方向吗?
问候,皮埃尔
Edit1:我试图比较两个私钥文件(亚马逊和公司)使用
openssl rsa -in yourkey.pem -check
并且都说
RSA key ok
writing RSA key
-----BEGIN RSA PRIVATE KEY-----
....
-----END RSA PRIVATE KEY-----
编辑2:1。看看duplicity-backendexception没有任何成功
有关信息,Paramiko 版本是 2.2.1
使用以下 python 脚本连接成功。
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']