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.
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?
here is a really detailed guide of how to set up the key
The SCP command allows you to copy a file or directory from a local system to a remote system, from a remote system to a local system, or between two remote systems from your local system. When you use the SCP command, you will need to provide a remote user's password before transferring a file.
Step1- create a normal file suppose "fileWithScpPassword" which contains the ssh password for the destination server. Step2- use sshpaas -f followed by password file name and then normal scp command. Save this answer.
Summary: Using scp to make remote backups without a passwordCreate a public and private key pair. Install your public key on remote Unix and Linux servers. ssh into your remote servers without a password. Use ssh to run commands on your remote servers without using a password.
The basic syntax is: scp user1@host1:filename user2@host2: where user1@host1 is the source from which you want to copy filename from and user2@host2 is the destination where you want the copy to go to.
You don't say which platform you are using at home and at school. Assuming Linux, Cygwin or OS/X you have several options:
For option (1), you would
For the second option, ssh-agent allows you to cache your password in a local process one time per session. You set an expiration time
Use "sshpass"!
#!/bin/bash
sshpass -p "password" scp -r /some/local/path [email protected]:/some/remote/path
Are ssh keys not allowed? That would be a better solution.
I don't think you can easily do that. What you can do is using public key authentication instead.
Something along these lines
ssh-keygen -t rsa
ssh school mkdir .ssh/
cat ~/.ssh/id_rsa.pub | ssh school "cat >>.ssh/authorized_keys"
(or dsa
).
But hey, it's not serverfault, is it? ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With