LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-15-2011, 05:59 AM   #1
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Rep: Reputation: 1
Remote connection with rsync


Hi Guys...

I want to copy files from one machine to another machine using rsync.

However, I have changed the default ssh port to 1234 (example)on the receiving server.
I have also stopped root login to the receiving server.

I am using the command:
Code:
nice rsync -aue 'ssh -p1234' --delete filess xxx.xxx.xxx.xxx:/
It then asks for password:
I put in the correct root password for the receiving server, and it returns:
Code:
Permission denied, please try again.
Does anybody have any ideas what I am doing wrong ???

Thanks,
 
Old 11-15-2011, 11:06 PM   #2
davemguru
Member
 
Registered: Apr 2006
Location: London
Distribution: Pclos,Debian,Puppy,Fedora
Posts: 87

Rep: Reputation: 42
Root is still root - regardless of login port

Quote:
Originally Posted by countrydj View Post
Hi Guys...

I want to copy files from one machine to another machine using rsync.

However, I have changed the default ssh port to 1234 (example)on the receiving server.
I have also stopped root login to the receiving server.

I am using the command:
Code:
nice rsync -aue 'ssh -p1234' --delete filess xxx.xxx.xxx.xxx:/
It then asks for password:
I put in the correct root password for the receiving server, and it returns:
Code:
Permission denied, please try again.
Does anybody have any ideas what I am doing wrong ???

Thanks,
Hi, I think the issue is that - no matter what "port" you login from - you are still trying to login as root. The ssh port 22 does not indicate who you are... so, changing it to 1234 -- only changes the conduit you are using - not your identity.
I assume that the user name you are logged in as (on the calling machine) is root? One can always specify username@machine - it makes it clearer. ALso, one can be logged in as user "Fred" and do the ssh/rsync as someone else - eg
Code:
nice rsync -aue 'ssh -p1234' --delete files womble@xxx.xxx.xxx.xxx:/
Perhaps I have misread your intentions? If so, I apologise.
However, I would question why you believe you need to be root in order to achieve your goal. I am guessing it is because you believe the "all encompassing" permissions of root - will permit you to do stuff that you could not otherwise?
There are many ways to skin the linux/rsync cat without compromising the security.
But, if you insist on becoming root - then why not set up some rsa keys so that the "calling machine" will be automatically authenticated by the "server" machine. I do this regularly for machines that I have a "long term relationship " with.
 
Old 11-16-2011, 11:20 AM   #3
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi davemguru...

Thank you for taking the time to respond.

Quote:
However, I would question why you believe you need to be root in order to achieve your goal. I am guessing it is because you believe the "all encompassing" permissions of root - will permit you to do stuff that you could not otherwise?
The reason that I need to be 'root'is that I want to transfer the whole of the /home directory.
There are around 40 web sites in there. Most are owned by me but a lot are owned by other users.
This means as me as user, I don't have enough permissions to copy and write to the receiving server.
I could only copy and write the directories and files that are owned my me.
 
Old 11-16-2011, 11:35 AM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
On the server, find your "sshd_config" file. This will usually be in an "/etc/ssh" directory, although some systems use "/etc" instead. We need to check the following lines in the file:

"PermitRootLogin" should be set to either "yes", "without-password", or "forced-commands-only".

the option without-password is not what you think, this requires public keys to be active and installed for authorizerd_keys.

just uncommenting PermitRootLogin yes should do it.

You will need to do that on the computer you are trying to get to. after making that change you will need to restart your sshd service.

in the RH line (including fedora and centos) service sshd restart will do it.
 
1 members found this post helpful.
Old 11-16-2011, 03:54 PM   #5
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi lleb...

Many thanks for taking the time to respond

I edited
Code:
/etc/ssh/sshd_config
to
Code:
PermitRootLogin without-password
I already had automatic login from server A to server B so I already had the authorizerd_keys.
This worked fine for me.
I still can't login ssh2 as 'root'. Which is what I want.

Quote:
just uncommenting PermitRootLogin yes should do it.
This allowed me to login as 'root' which is what I didn't want.

Thank you !!!

Last edited by countrydj; 11-16-2011 at 04:00 PM.
 
Old 11-17-2011, 06:43 AM   #6
davemguru
Member
 
Registered: Apr 2006
Location: London
Distribution: Pclos,Debian,Puppy,Fedora
Posts: 87

Rep: Reputation: 42
Quote:
There are around 40 web sites in there. Most are owned by me but a lot are owned by other users.
This means as me as user, I don't have enough permissions to copy and write to the receiving server.
I could only copy and write the directories and files that are owned my me.
I understand. Surely, to be "in line" with security - "you" (as user) should not be copying files that are "owned by other users"? Would it not make more sense to have crontab entries - owned by those users - that did the requisite rsync on their behalf? "You" (as administrator) setup the crontabs of course.

I only suggest this because your last sentence to lleb said
Quote:
This allowed me to login as 'root' which is what I didn't want.
So (somewhat confused) I think what you want is to
a) NOT be allowed to login as root on the remote server
AND
b) be permitted to transfer files (with the authority/permission of root) to the remote server.

Sort of ---- "root for the purposes of rsync transfer"??? Or more accurately - you want "rsync" to have permission to access any/all of the files you wish to transfer?
Am I close?
If so (and I can see why - from a security point of view) - then .... (if you don't like my suggestion of lots of individual users' crontabs) -- take a look at this thread.. http://www.linuxquestions.org/questi...s-root-340633/
Specifically "Dark Helmet"'s longer answer
Perhaps that is what you are chasing?
Dave
 
Old 11-17-2011, 10:19 AM   #7
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
yes sorry the root access is what that line will do, but also read the link i provided it will discuss how to set the dsa/rsa key so that it can ONLY rsync and do nothing else.
 
Old 11-17-2011, 10:53 AM   #8
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi davemguru
Thanks for joining in...

Just to explain:
I have had my server compromised.
I have blocked root ssh access and changed all, except ftp users, to 'nologin'
I also changed my ssh port to 1234 (example)
Now I have to login as myself (user) and then su to get root access.
Code:
I understand. Surely, to be "in line" with security - "you" (as user) should not be copying files that are
 "owned by other users"? Would it not make more sense to have crontab entries - owned by those users
 - that did the requisite rsync on their behalf? "You" (as administrator) setup the crontabs of course.
I am setting up a new server and need to transfer all the web sites from my current server to my new server.
It will be a few days before I switch over, but in the meantime I want to transfer the files and then keep them up to date.
I wanted to do this during the night automatically by setting up a cron job.

I setup 'automatic login' from my current server to my new server.
This works fine when root login is allowed, but not when it is blocked.

Hence the reason for my orignal post.

'leb' came up with the answer that solved my problem:
Code:
PermitRootLogin without-password
This is a 'one off' excersize, but in any event, as server administrator I have to backup all the web sites on a daily basis.
Therefore it wouldn't be practical to setup lots of cron jobs.

Hope this makes things clearer.

Thanks for all the help and advise that I have been given.

My problem is SOLVED
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't SSH to remote machine: Connection closed by remote host Avatar Linux - Networking 35 10-23-2017 12:21 AM
rsync - Remote to local gabriel01 Linux - Software 3 03-09-2011 08:40 AM
Trying to rsync from remote to local dooley28 Linux - Software 1 09-23-2010 01:03 AM
remote backup with rsync cattien Linux - Networking 1 09-15-2009 12:36 AM
rsync over two remote hosts Meson Linux - General 5 01-12-2008 08:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration