Ssh

如何在伺服器上安裝數據中心儲存,以便使用者可以遠端訪問它?

  • February 3, 2017

我需要在伺服器 A 上安裝一個儲存,以便從伺服器 B,我可以通過 scp 從 B 向 A 發送文件。

在伺服器 A 上,我正在嘗試將儲存安裝為:

# mount.cifs //u999999.your-storagebox.de/backup /storage/driveNumber -v -o user=u999999,pass=typeUrPasswordHere

掛載結果為:

# ls -la /storage 
total 8
drwxr-xr-x  3 root   root   4096 Feb  2 17:17 .
drwxr-xr-x 23 root   root   4096 Feb  2 17:16 ..
drwxrwxrwx  2 999999 999999    0 Feb  3 17:26 bx20_133060

但是,當我嘗試從伺服器 B(我現在的盒子)發送文件時,我得到了這個:

$ scp -v -p -P 45789 mysql-incremental.tar.gz slammer@d2.wearebionic.com:/storage/bx20_133060
Executing: program /usr/bin/ssh host d2.wearebionic.com, user slammer, command scp -v -p -t /storage/bx20_133060
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to d2.wearebionic.com [136.243.80.14] port 45789.
debug1: Connection established.
debug1: identity file /home/gtl/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/gtl/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to d2.wearebionic.com:45789 as 'slammer'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ue89Au5xEc1UIDcLMwNhTGWuHP7vwJwNHtQbaYo0cUI
debug1: Host '[d2.wearebionic.com]:45789' is known and matches the ECDSA host key.
debug1: Found key in /home/gtl/.ssh/known_hosts:8
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/gtl/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to d2.wearebionic.com ([136.243.80.14]:45789).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_PAPER = en_IE.UTF-8
debug1: Sending env LC_ADDRESS = en_IE.UTF-8
debug1: Sending env LC_MONETARY = en_IE.UTF-8
debug1: Sending env LC_NUMERIC = en_IE.UTF-8
debug1: Sending env LC_TELEPHONE = en_IE.UTF-8
debug1: Sending env LC_IDENTIFICATION = en_IE.UTF-8
debug1: Sending env LANG = en_IE.UTF-8
debug1: Sending env LC_MEASUREMENT = en_IE.UTF-8
debug1: Sending env LC_TIME = pt_BR.UTF-8
debug1: Sending env LC_NAME = en_IE.UTF-8
debug1: Sending command: scp -v -p -t /storage/bx20_133060
File mtime 1485968603 atime 1486140418
Sending file timestamps: T1485968603 0 1486140418 0
Sink: T1485968603 0 1486140418 0
Sending file modes: C0777 75337 mysql-incremental.tar.gz
Sink: C0777 75337 mysql-incremental.tar.gz
scp: /storage/bx20_133060/mysql-incremental.tar.gz: Permission denied
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 3336, received 2708 bytes, in 0.2 seconds
Bytes per second: sent 13686.3, received 11109.9
debug1: Exit status 1

我做錯了什麼以及如何改正?

僅使用scp 我將首先在伺服器 A 和伺服器 B 之間直接驗證它,然後將您storagebox排除在外。

從每台伺服器嘗試類似 scp somefile.txt otherserver:/home/gtludwig/

如果這不起作用,那麼問題會更加簡化,ssh並且scp與每個伺服器之間的安全性有關。

但我懷疑問題在於使用者、文件和目錄權限未在storagebox您安裝到的伺服器之間同步。如果storageboxcifs 是某些通過某些 Windows 域伺服器進行身份驗證的儲存設備,則尤其如此……從技術上講,這將是伺服器 C。還知道管理員storagebox可以簡單地限制可以掛載storagebox的設備,無論使用者名和密碼是否正確storagebox. 這相當於將 linux NFS 導出限製到給定主機,如/etc/exports.

但是從您提供的資訊看來,正在發生的事情是您已storagebox安裝server_A並且 mount.cifs 是在使用者下定向的,u999999 但是在使用時,scp您是在使用者下通過 SSH 連接到 Server_A,slammer因此權限被拒絕。

從 Server_A 首先確保storagebox已成功掛載,然後作為使用者u999999您可以成功將文件上傳到storagebox. 然後嘗試scp進入 server_A as u999999,或確保您使用的使用者名/使用者 IDscp與用於掛載 cifs 共享的使用者名/使用者名相同。

引用自:https://unix.stackexchange.com/questions/342324