gpt4 book ai didi

ssh - 使用 ssh 从 Linux 服务器发出备份命令

转载 作者:行者123 更新时间:2023-11-30 01:15:21 24 4
gpt4 key购买 nike

我是 ssh 和 mysql 命令的 mewbie。我在使用无密码身份验证从一台 Linux 服务器到另一台 Linux 服务器进行备份时遇到问题。我已经生成了用于无密码身份验证的 key 并将其上传到另一台服务器。

我用过这个命令

[user1@server1 ~]$ mysqldump -u dbuser -p"dbpwd" --opt  dbname | gzip -c | ssh  -o StrictHostKeyChecking=no -o UserKnownHostsFile=/...../known_hosts -l deploy -i  /...../id_rsa -v  user2@server2  "/bin/cat > user2@server2:/......./test.sql.gz" 2>&1 

现在,当我在 SSH 中运行命令时,出现以下错误

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_20082' not found

debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_20082' not found

debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Next authentication method: publickey
debug1: Offering public key: /home/indus33/.ssh/id_rsa

我用谷歌搜索了很多,但没有解决方案帮助我。

如果有人对此有疑问,请经常询问我。

请帮我解决这个问题。

已更新

我运行命令

[user@server1 ~]$ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/..../known_hosts -l 部署 -i/..../id_rsa -v user2@server2

错误

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /.../ssh_config
debug1: Applying options for *
debug1: Connecting to server2IP [server2IP] port 22.
debug1: Connection established.
debug1: identity file /......./id_rsa type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'server2IP' is known and matches the RSA host key.
debug1: Found key in /......./known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_20082' not found

debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_20082' not found

debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Next authentication method: publickey
debug1: Offering public key: /....../id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Mon Sep 30 03:25:52 2013 from server1
user2@server2 [~]#

希望大家都能清楚这个问题......

最佳答案

首先在server2上创建authorized_keys的最佳方法

 touch /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

然后将id_rsa.pub的内容复制到服务器即可

[user1@server1 ~]$ cat ~/.ssh/id_rsa.pub | ssh user2@server2 "cat >> ~/.ssh/authorized_keys"

然后在 server1 上发出以下 mysqldump 命令

[user1@server1 ~]$ mysqldump -u dbuser -p"dbpwd" --opt  dbname | gzip -c | ssh user2@server2 "/bin/cat > /your_path/test.sql.gz" 2>&

关于ssh - 使用 ssh 从 Linux 服务器发出备份命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19114942/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com