Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am frequently updating files from a development enviroment to a production one in different servers so the paths are the same in both hosts and it becomes kind of a repetitive procedure to update a file and indicate the same path for the scp parameters.

Is there a way to use brace expansion or other technique with scp parameters? I know one of them, origin or destination must include the user@host: at the start.

What I am trying to do is something like:

scp user@{dev-server,production-server}:/path/to/file
share|improve this question
Why not do just that, with the braces? –  Gilles Aug 3 '12 at 23:43
scp isn't working with brace expansion (braces). Any example? –  altmas5 Aug 5 '12 at 19:54
Brace expansion is performed by the shell, not by scp. The command you wrote is expanded by the shell into scp user@dev-server:/path/to/file user@production-server:/path/to/file. –  Gilles Aug 5 '12 at 20:16

2 Answers 2

up vote 4 down vote accepted

I propose two solutions not all using scp:

1. Use .ssh/config to help

Ie: put something like this in your .ssh/config

Host p
HostName production.domain.com
Host d
HostName development.domain.com

Then you can shorten your scp command:

scp user@d:/path user@p:/path

2. Use source control software like git. So when you're done with debugging and coding and stuff, you do this (simplified):

git add /path/to/my_file
git commit -m "new version and features done"
git push production master

(Just setup your git to use ssh)

3. Use qscp, or quick-scp - a bash script designed especially for your convenience :) https://github.com/zladuric/quick-scp Basically, get the qscp file and make it executable. (and change the defaults to your environment).

It will take one mandatory and two optional parameters. Example:

./qscp file     # it will use defaults
./qscp path/to/dir  dest.server.com # uses default source, but to other dest
./qscp /abs/path/to/file dest.srv.com src.srv.com # takes both dest and source server args

The scrpt should be easy to customize to your specific needs, but it is not extremely robust yet. You may have to adjust location of the scp binary, your ssh_key files or something similar.

How about them apples? :)

share|improve this answer
I want to avoid typing the path 2 times not the hostnames.I know using a SCM is the right solution for updating my production server but is not an option right now. –  altmas5 Aug 5 '12 at 20:19
ok, then qscp is created as your answer :) but of course, it will mostly use as a guideline so you can work with that :) –  Zlatko Aug 6 '12 at 11:28
awesome, I will take a look of it. Thank you –  altmas5 Aug 6 '12 at 17:14

I think it is better to alias the command which you are executing everytime to even reduce typing.

Add the command in the .bashrc file of the user:

alias tx='scp user@{dev-server,production-server}:/path/to/file'

This will help to reduce the typing errors which may happen while typing the whole command.

But I think the way you are this doing is not correct at all. As zladuric told in the second way, you should use some version control system to maintain you code database. This will allow you to revert back to any previous version.

share|improve this answer
scp is not accepting brace expasion, so the alias is not going to work either. –  altmas5 Aug 5 '12 at 19:53
this is because ur scp syntax is wrong..it shud be something like: scp /path/to/file user@roduction-server:/path/to/file –  pradeepchhetri Aug 5 '12 at 20:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.