使用 scp 时权限被拒绝,但可以使用 ssh

使用 scp 时权限被拒绝,但可以使用 ssh

我正在尝试将文件从本地桌面复制到远程服务器。

是的 - 我想要复制到的远程目录设置为是chmod 777 - 服务器受密码保护,并且我确信我有正确的密码,因为我能够 ssh 连接到服务器。

该服务器用于 Drupal 7 网站,我尝试过吉特巴什和 Windows PowerShell,在 Windows 10 系统上。服务器受保护和管理,思科 Anyconnect盔甲

我不知道问题是什么。有人能提供一些指导吗?

谢谢!

我的调试输出(我已将用户名<my-user>和 IP 地址替换为xxx.xxx.xx.xx):

PS C:\Users\Jill> scp -v ~/logo.png <my-user>@xxx.xxx.xx.xx:/var/www/html/sites/all/themes/bootstrap/bootstrap_subtheme
Executing: program ssh.exe host xxx.xxx.xx.xx, user <my-user>, command scp -v -t /var/www/html/sites/all/themes/bootstrap/bootstrap_subtheme
OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
debug1: Connecting to xxx.xxx.xx.xx [xxx.xxx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\Jill/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\Jill/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to xxx.xxx.xx.xx:22 as '<my-user>'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:5pwb0K9Lm5jDfTygWxEht/0ANL/5/kpCNlZDm/tV3ww
debug1: Host 'xxx.xxx.xx.xx' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\Jill/.ssh/known_hosts:5
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX C:\\Users\\Jill/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: C:\\Users\\Jill/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\Jill/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\Jill/.ssh/id_ed25519
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such file or directory
[email protected]'s password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such file or directory
[email protected]'s password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such file or directory
[email protected]'s password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection

答案1

尝试复制到主目录或其他目录(您将能够确定是否是权限问题),然后复制到您实际要复制的位置。

答案2

是的,正如 Siya 所建议的,您需要使用这里的命令和示例提供 pem 密钥。

格式 :

scp -i [server-pem-key] -r [path or file name to copy] [ec2-username]@server-ip:[path-to-copy-on-target-server]

例子 :

scp -i server-key-pair.pem -r /home/folder [email protected]:/home/ec2-user

答案3

我遇到了同样的问题,结果发现我没有在 scp cmd 中提供 pem 密钥。当我在 cmd 中提供 pem 密钥时,它运行正常

相关内容