0

I'm using Mac 10.9.5 and bash shell. In our environment, we have to go through a proxy (a CentOS machine) to SSH properly into a destination machine (another CentOS machine). What I would like to do is create a shortcut so that I can scp files quickly to the destination server, something like

scp localfile.txt davea@server:/home/davea

But right now, I have to do multiple commands to transfer the file …

scp localfile.txt davea@proxy:/home/davea
ssh davea@proxy
scp localfile.txt davea@server:/home/davea

Is it possible to condense the above into one line?

Dave
  • 1

2 Answers2

1

How about a function in you .bash_profile

scps () {
    if [ -f $1 ] ; then
        scp $1 davea@proxy:/home/davea && ssh davea@proxy && scp $1 davea@server:/home/davea
    else
        echo "'$1' is not a valid file!"
    fi
}

Then you can use scps filename to copy filename to davea@server:/home/davea.

jherran
  • 1,949
0

Consider using rsync to automatically copy files from the proxy to the destination:

rsync local-file user@remote-host:remote-file
Andreas F
  • 343