assignment for CSCI 596: Scientific Computing & Visualization
For convenience, write *.expect scripts to log into SFTP and SSH automatically.
You need to install expect first. For example in Mac OS X, using
brew install expect
File login-sftp.expect:
#!/usr/bin/expect
set timeout 30
spawn sftp username@host-name
expect "*password: "
send "your-password\r"
expect "sftp> "
interact
File login-ssh.expect:
#!/usr/bin/expect
set timeout 30
spawn ssh username@host-name
expect "*password:"
send "your-password\r"
interact
To use these, just use command below in the Terminal (assuming $PATH_LOGIN is the directory where the expect scrips are):
expect $PATH_LOGIN/login-ssh.expect
or
expect $PATH_LOGIN/login-sftp.expect
Further more, we can use alias to make it more faster, add lines below in ./zshrc (since I use zsh):
alias login_ssh="expect $PATH_LOGIN/login-ssh.expect"
alias login_ssh="expect $PATH_LOGIN/login-ssh.expect"
Then type key esc and :wq to save it.
Then enter command below in Terminal:
source ./zshrc
Now you can use command login_ssh
/login_sftp
directly to connect to the remote host!
SSH login output: