Created
April 3, 2013 21:12
-
-
Save darrylhebbes/5305347 to your computer and use it in GitHub Desktop.
A script to pass password to SSH Rsync session, without using SSH Keys. NOTE: this is not a wise solution but useful in certain situations.
Usage example 1: "./rsync-app.sh B" will spawn the Rsync in the second block, "./rsync-app.sh ABC" will run all three.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set MachineName "Macintosh HD" | |
set MachineUserProfile "computerprofile" | |
set ProjectPath "htdocs/yourlocalprojectname" | |
set RemoteLogin "[email protected]" | |
set RemoteProjectPath "/htdocs/myproject" | |
set PASSPH "theSSHpassword" | |
send_user "\n" | |
stty -echo | |
if { [lindex $argv 0] == "A" || [lindex $argv 0] == "ABC" } { | |
spawn rsync -aihv --exclude '.git' --exclude '.DS_Store' -e ssh "/Volumes/$MachineName/Users/$MachineUserProfile/$ProjectPath/htdocs/application/layouts/" "$RemoteLogin:$RemoteProjectPath/htdocs/application/layouts/" | |
expect "password:" | |
send "$PASSPH\n" | |
expect "#" | |
} | |
if { [lindex $argv 0] == "B" || [lindex $argv 0] == "ABC"} { | |
spawn rsync -aihv --exclude '.git' --exclude '.DS_Store' -e ssh "/Volumes/$MachineName/Users/$MachineUserProfile/$ProjectPath/htdocs/application/controllers/" "$RemoteLogin:$RemoteProjectPath/htdocs/application/controllers/" | |
expect "password:" | |
send "$PASSPH\n" | |
expect "#" | |
} | |
if { [lindex $argv 0] == "C" || [lindex $argv 0] == "ABC"} { | |
spawn rsync -aihv --exclude '.git' --exclude '.DS_Store' -e ssh "/Volumes/$MachineName/Users/$MachineUserProfile/$ProjectPath/htdocs/application/views/" "$RemoteLogin:$RemoteProjectPath/htdocs/application/views/" | |
expect "password:" | |
send "$PASSPH\n" | |
expect "#" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment