On Sun, March 1, 2015 10:22 am, Richard wrote:> > > ------------ Original Message ------------ >> Date: Sunday, March 01, 2015 10:44:08 -0500 >> From: Mark LaPierre <marklapier at gmail.com> >> To: centos at centos.org, Mark LaPierre <marklapier at aol.com> >> Subject: Re: [CentOS] scp -rp behavior(SOLVED) >> >> On 02/26/15 19:45, Valeri Galtsev wrote: >>> >>> On Thu, February 26, 2015 6:34 pm, Mark LaPierre wrote: >>>> Hey all, >>>> >>>> I'm trying to copy configuration files from my old CentOS 6.6 32 >>>> bit machine to my new CentOS 6.6 64 bit machine. >>>> >>>> On my 32 bit machine: >>>> >>>> [mlapier at mushroom ~]$ ifconfig >>>> eth0 Link encap:Ethernet HWaddr 00:19:DB:E5:4E:9F >>>> inet addr:192.168.15.105 >>>> >>>> When I issue this command on my new 64 bit machine, >>>> 192.168.15.101: >>>> >>>> scp -pr mlapier at 192.168.15.105: /home/mlapier/.thunderbird >>>> /home/mlapier/.thunderbird >>> >>> How about escaping dot (with backslash) for the remote machine, >>> or just giving the whole path for remote machine in quotes: >>> >>> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird" >>> /home/mlapier >>> >>> ? >>> >>> Also, if you want to specify destination directory (say with >>> different name) you will need to end directory with forward slash >>> both on local and remote, like: >>> >>> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird/" \ >>> /home/mlapier/.thunderbird/ >>> >>> (this should be one line which didn't fit for me in one line hence >>> backslash...) >>> >>> Valeri >>> >>>> >>>> It copies all directories and files in 192.168.15.105: >>>> /home/mlapier/ to 192.168.15.101: /home/mlapier. I don't want >>>> all that, I just want the .thunderbird folder and all it's >>>> contents. >>>> >>>> The user and group account numbers match on the two machines for >>>> this user so that's not the issue. >>>> >>>> When I RTFM this is what I thought it said to do. I'm I >>>> misreading the FM or is something weird going on here? >>>> >> >> Putting the source path in quotes, because of the dot, like this: >> >> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird" >> /home/mlapier >> >> worked. >> >> If the destination also contains a dot or other such character >> then put the destination in quotes too: >> >> scp -pr mlapier at 192.168.15.105:"/home/mlapier/.thunderbird" >> "/home/mlapier/.thunderbird" >> >> but only include the destination directory if the destination >> directory does not yet exist otherwise you will get a copy of the >> source directory inside the destination directory like this: >> >> /home/mlapier/.thunderbird/.thunderbird > > > The problem is/was the space, after the colon, in your command: > > scp -pr mlapier at 192.168.15.105: /home/mlapier > > quotes, slashes, etc. are totally unnecessary. > > If you are keeping the destination name the same as the source, you > only need to use a "." (dot) for the target (whether the destination > directory/file already exists or not), not the full name. You only > need a path on the target side if you are trying to put the > directory/file in other than the home directory of the user you are > logging in as. > > So, assuming you were in your home directory on the source side, all > you needed is/was: > > scp -pr mlapier at 192.168.15.105:.thunderbird . >Well, you are right about dot for local argument, namely "dot" is expanded on local machine into "path to current directory". For remote machine, however, you do have to specify absolute path to the directory you intend to rsync or scp. In your example remote directory quite likely does not exist, as your command is exact equivalent of this: scp -pr mlapier at 192.168.15.105:/.thunderbird . whereas you may want to have: scp -pr mlapier at 192.168.15.105:/home/remote_user_name/.thunderbird . Why "slash": /.thunderbird in case of your example? Because if you do not specify absolute path beginning with / the ssh daemon prepends your relative path with its `pwd` it runs in, and its `pwd` is "/") Another way to specify remote user's home directory would be: scp -pr mlapier at 192.168.15.105:"~/.thunderbird" . and here quotes prevent "~" from being expanded on local machine, thus "~" is passed verbatim to remote machine and is expanded on remote machine into path to remote user's home directory. I hope I didn't mess up anything here ;-) Valeri ++++++++++++++++++++++++++++++++++++++++ Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247 ++++++++++++++++++++++++++++++++++++++++
On Sun, Mar 01, 2015 at 10:58:30AM -0600, Valeri Galtsev wrote:> Why "slash": /.thunderbird in case of your example? Because if you do not > specify absolute path beginning with / the ssh daemon prepends your > relative path with its `pwd` it runs in, and its `pwd` is "/")I'm not sure I understand what you're saying here... Are you saying that if I run 'scp remotehost:.bashrc ." it will copy /.bashrc from remotehost, regardless of whether my $HOME on remotehost is /home/username ? -- Jonathan Billings <billings at negate.org>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 <big snip>> Why "slash": /.thunderbird in case of your example? Because if you > do not specify absolute path beginning with / the ssh daemon > prepends your relative path with its `pwd` it runs in, and its > `pwd` is "/")Not so. Consider: $ ssh pi-1 pwd /home/jmr If you examine what is happening, the daemon creates an unprivileged process for the user, and that process performs the operation. Were it to be otherwise you would have a gaping hole in security. $ ssh pi-1 ps -f UID PID PPID C STIME TTY TIME CMD jmr 3054 3050 0 04:22 ? 00:00:00 sshd: jmr at notty jmr 3055 3054 0 04:22 ? 00:00:00 ps -f $ ssh pi-1 ps -ef | grep ssh root 2432 1 0 Feb28 ? 00:00:00 /usr/sbin/sshd root 3056 2432 0 04:23 ? 00:00:00 sshd: jmr [priv] jmr 3060 3056 0 04:23 ? 00:00:00 sshd: jmr at notty The first command shows the unprivileged process shelling out the ps command as expected. Note that the parent daemon is running as jmr at notty. The second command shows master daemon, the privileged child to handle the connection and the unprivileged jmr at notty. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJU80j0AAoJEAF3yXsqtyBlr0EQAJNyKbeBSu0F22dqe+cIiTfl yydfgvCsqmg2xiAz4oQgiqHoYqjcj4XihnIclCmsrw+My4WAy5Yer59NVl/tVYPh n0YOAm2oobHTYL4rse/eeFUUga19JD1JAwCrs/k3GQwDXaoBf9PXcRAQBo4q44Mx peA7T9Fmb7eosz3xVS74hOeYFTPdOOMSr17ygGuyM9Q0vHgg3EyDUUPjotsp7eRe vr9eQI64DgPL1Q01BdZYqseHbLNxkCjL1tuDRy8Qzrj2i4S4JEPB8h8VJWVssoQw J6IqWz3hHi+9ecl5AX/jTdlgxUK7rhogMmQ7YanqA4MGCSZQkOmk7jz59ocD0S6q sswJVUOHbV1DVKCFR/G2SOfYecp9iIti5az58v4nPMzK/X8coB1ZeB9cZlKpGh94 2UU34UmynvgCSsw3THqS3QgTE4VtPAVtyLJWFjK+E+ilsJ6b84emEWoSZ/b7RhTg kADyr/xlmX6xXOUBQsME9ExfTVsKJv+wj02tFaxhEkup3bS2twAbRPprSy66TZXD 5OD8Nyz3lxSl1Z2qy7KzYhf3gY5gcYDXgtRPcNiM2sWOZTmoo+ZKJQVeVMyZ+inf 0Vls5joJrRi93XfVuWMijnT/A4aCAhbUBlPye7sX6uy96ButBsk/rAaolzNh1PdH Htsbqx50fPZbzNfyZ2BB =LGml -----END PGP SIGNATURE-----
On Sun, March 1, 2015 11:14 am, J Martin Rushton wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > <big snip> > >> Why "slash": /.thunderbird in case of your example? Because if you >> do not specify absolute path beginning with / the ssh daemon >> prepends your relative path with its `pwd` it runs in, and its >> `pwd` is "/") > > Not so. Consider:Indeed you are right. My bad. It starts worker process as user=remote user with pwd his home directory. Thanks for correcting the stupid idiot (which will be me)> > $ ssh pi-1 pwd > /home/jmr > > If you examine what is happening, the daemon creates an unprivileged > process for the user, and that process performs the operation. Were > it to be otherwise you would have a gaping hole in security. > > $ ssh pi-1 ps -f > UID PID PPID C STIME TTY TIME CMD > jmr 3054 3050 0 04:22 ? 00:00:00 sshd: jmr at notty > jmr 3055 3054 0 04:22 ? 00:00:00 ps -f > $ ssh pi-1 ps -ef | grep ssh > root 2432 1 0 Feb28 ? 00:00:00 /usr/sbin/sshd > root 3056 2432 0 04:23 ? 00:00:00 sshd: jmr [priv] > jmr 3060 3056 0 04:23 ? 00:00:00 sshd: jmr at notty > > The first command shows the unprivileged process shelling out the ps > command as expected. Note that the parent daemon is running as > jmr at notty. The second command shows master daemon, the privileged > child to handle the connection and the unprivileged jmr at notty. > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.22 (GNU/Linux) > > iQIcBAEBAgAGBQJU80j0AAoJEAF3yXsqtyBlr0EQAJNyKbeBSu0F22dqe+cIiTfl > yydfgvCsqmg2xiAz4oQgiqHoYqjcj4XihnIclCmsrw+My4WAy5Yer59NVl/tVYPh > n0YOAm2oobHTYL4rse/eeFUUga19JD1JAwCrs/k3GQwDXaoBf9PXcRAQBo4q44Mx > peA7T9Fmb7eosz3xVS74hOeYFTPdOOMSr17ygGuyM9Q0vHgg3EyDUUPjotsp7eRe > vr9eQI64DgPL1Q01BdZYqseHbLNxkCjL1tuDRy8Qzrj2i4S4JEPB8h8VJWVssoQw > J6IqWz3hHi+9ecl5AX/jTdlgxUK7rhogMmQ7YanqA4MGCSZQkOmk7jz59ocD0S6q > sswJVUOHbV1DVKCFR/G2SOfYecp9iIti5az58v4nPMzK/X8coB1ZeB9cZlKpGh94 > 2UU34UmynvgCSsw3THqS3QgTE4VtPAVtyLJWFjK+E+ilsJ6b84emEWoSZ/b7RhTg > kADyr/xlmX6xXOUBQsME9ExfTVsKJv+wj02tFaxhEkup3bS2twAbRPprSy66TZXD > 5OD8Nyz3lxSl1Z2qy7KzYhf3gY5gcYDXgtRPcNiM2sWOZTmoo+ZKJQVeVMyZ+inf > 0Vls5joJrRi93XfVuWMijnT/A4aCAhbUBlPye7sX6uy96ButBsk/rAaolzNh1PdH > Htsbqx50fPZbzNfyZ2BB > =LGml > -----END PGP SIGNATURE----- > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >++++++++++++++++++++++++++++++++++++++++ Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247 ++++++++++++++++++++++++++++++++++++++++
On Sun, March 1, 2015 11:08 am, Jonathan Billings wrote:> On Sun, Mar 01, 2015 at 10:58:30AM -0600, Valeri Galtsev wrote: >> Why "slash": /.thunderbird in case of your example? Because if you do >> not >> specify absolute path beginning with / the ssh daemon prepends your >> relative path with its `pwd` it runs in, and its `pwd` is "/") > > I'm not sure I understand what you're saying here... > > Are you saying that if I run 'scp remotehost:.bashrc ." it will copy > /.bashrc from remotehost, regardless of whether my $HOME on remotehost > is /home/username ? >Well, I was wrong, and somebody already corrected the stupid idiot (me). I forgot that the worker process is started as user=remote user with pwduser's home directory. So what I said about absolute path _necessary_ it total nonsense. ;-( I guess I need more coffee in the morning on Sunday... Valeri ++++++++++++++++++++++++++++++++++++++++ Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247 ++++++++++++++++++++++++++++++++++++++++