Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想编写一个 shell 脚本,它使用 SFTP 将文件从另一台服务器复制到我的盒子,而不提示输入密码,因为我已经为服务器上的密码创建了 private keygen。你能给我提供示例脚本吗?
您可以使用scpwhich 适用于ssh协议并读取私钥:
scp
ssh
scp -r path/to/src/folder1 username@server:/path/to/dst/folder
开关是-r递归复制
-r
如果需要指定端口,请使用-p
-p
scp -r -P 2222 path/to/src/folder1 username@server:/path/to/dst/folder