Automatic scp command

Secure Copy or SCP is a means of securely transferring computer files between a local and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. When we use this command, we must prompt password to copy file from other host. We can use upload public key for automatic, but we can use other method to bypass input password.

Expect is a useful tool for feeding inputs automatically to an interactive program. Expect  is a program that “talks” to other interactive programs accord‐ing to a script. This is a sample code to bypass password when use scp command :


set timeout 30
spawn /usr/bin/scp /home/toto/ angel@
expect {
          send "your_password\r"

This is a simple script to bypass command from konsole. You can use other command (ex. ssh, ftp, etc) with expact, so you can bypass other parameter from that command.

Source :

Add a Comment

Your email address will not be published. Required fields are marked *