当我尝试使用 scp -r 传输文件时权限被拒绝

当我尝试使用 scp -r 传输文件时权限被拒绝

当我运行此代码时出现错误:

 scp  -r ./build/* rose@IP_address:/var/www/mywebsite.com/html
Permission denied(publickey)
lost connection

它第一次工作,但当我想对我的 create-react-app 网站应用一些更改时,它就不起作用了。

这是一个片段

scp -vvv  -r ./build/* rose@IP_address:/var/www/mywebsite.com/html
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "IP_address" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to IP_address [IP_address] port 22.
debug1: Connection established.
debug1: identity file /home/rose/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/rose/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rose/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rose/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rose/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rose/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rose/.ssh/id_ed25519 type -1

请帮忙。

答案1

所以我找到了解决这个问题的方法。我去了

sudo nano /etc/ssh/sshd_config

PasswordAuthentication no改为PasswordAuthentication yes

PermitRootLogin noPermitRootLogin yes

然后跑了sudo systemctl restart sshd又跑ssh user@IP_address,就成功了。

相关内容