我对同步或 SSH 不太有经验。但我正在尝试将本地 Linux 计算机上的文件夹同步到远程网络服务器(本地和远程运行的 ubuntu)。当我在本地计算机上尝试此操作时:
sudo rsync -ahvz --progress /localshare/ myname@xxx:/var/www/html/upload/
我第一次得到这个:
The authenticity of host 'x.x.x.x' can't be established.
ECDSA key fingerprint is SHA256:BkWg7o5BlblILzWh4d1hIcg0OsWCOu/04wkLM45XuS8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
之后我再次尝试了第一个命令:
Permission denied (publickey).
所以我在本地机器上运行 ssh-keygen
ssh-keygen -t -rsa -C "mymailadress@com" -f ~/.ssh/id_rsa -P ""
并在适当的文件夹中生成公钥/私钥 rsa 密钥对...
怎么办?我可以完全访问远程服务器(运行 apache)
答案1
需要将内容复制~/.ssh/id_rsa.pub
到~/.ssh/authorized_keys
服务器上:
mkdir ~/.ssh && chmod 700 ~/.ssh
vim ~/.ssh/authorized_keys # edit file and paste your public key
chmod 600 ~/.ssh/authorized_keys