Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

How do I scp files from server_a --> server_b while changing permissions

I have a set of files on server_a (server_a:/orig_files/) and want to scp them to server_b (server_b:/copied_files/) nut want to change the permissions along the way.

So, given the files on server_a with the indicated permissions:
[mike@server_a orig_files]# ll
-rw-r--r--    1 mike     users        22744 Feb 15 01:17 install.log
-rw-r--r--    1 mike     users         4371 Feb 15 01:17 install.log.syslog

How do I scp them to server_b such that they have different permissions as seen below:
[mike@server_b copied_files]# ll
-rw-------    1 mike     users        22744 Feb 15 01:17 install.log
-rw-------    1 mike     users         4371 Feb 15 01:17 install.log.syslog

Can 'scp' change permissions on the fly like this? I cannot change the permissions of the files on server_a first and the files must be "pushed" from server_a to server_b (i.e. server_b has no route to server_a, but server_a has a route to server_b).

Any thoughts?
0
mikestan
Asked:
mikestan
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
ravenplCommented:
> Can 'scp' change permissions on the fly like this?
No. You need do it in two steps - either change perm on source files, then copy; or copy then change permissions on the remote...

> (i.e. server_b has no route to server_a, but server_a has a route to server_b).
It's impossible - both hosts have to have route to another - otherwise connection can't be established(as packets back get dropped) ;)
0
 
pjedmondCommented:
> (i.e. server_b has no route to server_a, but server_a has a route to server_b).
It's impossible - both hosts have to have route to another - otherwise connection can't be established(as packets back get dropped) ;)

....not quite 'impossible'....but pretty close to it, and definitely more complicated and less reliable;) UDP doesn't require return packets.....and you have to be able to guarantee the integrity of the link!

Also, what about a 3rd server with a connection to server a and server b? If it's got sshd running, then you could use port forwarding:

server_a:

ssh -L port:server_b:22 user@server_c              (effectively makes localhost port, server_b)

scp /orig_files/ -P port user@localhost:/orig_files/

For changing remote file permissions:

ssh user@hostname command

HTH:)
0
 
ravenplCommented:
True - UDP (one way may work)

Creating tunnel makes the route in fact - the remote is accessible/routed via localhost - right ?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
mikestanAuthor Commented:
>> (i.e. server_b has no route to server_a, but server_a has a route to server_b).
>> It's impossible - both hosts have to have route to another - otherwise connection can't be established(as packets back get dropped) ;)

> ....not quite 'impossible'....but pretty close to it, and definitely more complicated and less reliable;) UDP doesn't require
> return packets.....and you have to be able to guarantee the integrity of the link!

There's actually a firewall between the two servers (don't know policy), which is why I cannot "pull" the files from server_b but server_a can "push" files to server_b.
0
 
pjedmondCommented:
Ravenpl has a point there - provided a tunnel is created either as explained above.....or indeed any vpn solution, you can pull rather than push if you wish. Worth looking at openVPN for this, as I consider it to be the easiest VPN to configure as no kernel 'messing' is required:

http://openvpn.net/

Then the firewall becomes irrelavent as everything is tunnelled through it.
0
 
ahoffmannCommented:
> There's actually a firewall between the two servers (don't know policy), which is why I cannot "pull" the files from server_b but server_a can "push" files to server_b.
this observed behaviour does not mean that there is no route from server_b to server_a, it's just the firewall policy which does not allow it, probably.

As there're firewall policies, I'd not use ssh tunnels to break the rules, for obvious reason, ask your admin.
0
 
ravenplCommented:
Or maybe rsynch (archive mode -a) over ssh tunnel would do?
0
 
pjedmondCommented:
>As there're firewall policies, I'd not use ssh tunnels to break the rules, for obvious reason, ask your admin.

ahoffmann - Where's your sensense of fun;)
0
 
ahoffmannCommented:
pjedmond, I missed one of the smileys :-/ or |-: or ;-)
0
 
mikestanAuthor Commented:
After much thought, I liked the answer, "[You can't do it]," the best. Thanks for the discussion and suggestions.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now