在 shell 脚本中使用 SCP 时如何响应密码提示?脚本、提示、密码、shell

2023-09-06 22:59:40 作者:回头牵你的手

首先,我很清楚有很多关于这个话题的问题.我已经阅读了它们,但仍然可以为我的情况找到一个合适的答案.

First of all, I am well aware of that there are many of questions regarding this topic. I have read them, but still could figure out an appropriate answer for my situation.

我想用 shell 脚本 scp 从本地到学校主目录的整个 ~/cs###/assign1 目录.我的问题是,我的脚本中有没有办法等待密码提示,然后模拟键盘事件来输入"我的密码?

I would like to scp the entire ~/cs###/assign1 dir from local to school home dir with a shell script. My question is, is there a way in my script to wait for the password prompt, and then simulate key board event to 'type' in my password?

这里是关于如何设置密钥的非常详细的指南p>

here is a really detailed guide of how to set up the key

推荐答案

ssh key 不被允许?这将是一个更好的解决方案.

Are ssh keys not allowed? That would be a better solution.