🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
16 messages
16 total messages Started by John F. Morse Tue, 04 Aug 2009 05:11
Authentication for rsync over ssh failing
#81737
Author: John F. Morse
Date: Tue, 04 Aug 2009 05:11
87 lines
4041 bytes
I'm trying to connect to and fetch INN status files from a remote news
server ("inn2") and make them available on apache.

I manually (remotely via an ssh BASH session) run an rsync copy from
/var/spool/news on an Apache Webserver ("apache").

I can't get it to work, and it must work before I can put the routine
into a cron job on apache to automate it.

Working only as user "news" on both computers, I have the proper keys
created ("ssh-keygen -t rsa") with no passphrase. The created id_rsa.pub
key was copied to "authorized_keys" and then scp'd to
/var/spool/news/.ssh/authorized_keys on inn2.

Then on the apache server I entered the following command:

news@apache:~/.ssh$ rsync -avvzn -e "ssh -i
/var/spool/news/.ssh/authorized_keys" news@inn2:/var/spool/news/testfile .

[That is a dot at the end of the command to signify user news' home
directory, where "testfile" resides.]

The following was reported on apache:

opening connection using: ssh -i /var/spool/news/.ssh/authorized_keys -l
news inn2 rsync --server --sender -vvnlogDtprze.iL .
/var/spool/news/testfile

A tail of /var/log/auth.log on inn2 shows the following:

Aug  3 22:39:36 inn2 sshd[947]: Authentication refused: bad ownership or
modes for directory /var/spool/news

Hmmmm.... More about this below.

Back in the ssh session on apache:

news@inn2's password:

[I manually enter the password]

The tail of /var/log/auth.log on inn2 shows the following:

Aug  3 22:40:59 inn2 sshd[947]: Accepted password for news from
xx.xx.xx.xx port 60008 ssh2
Aug  3 22:41:00 inn2 sshd[947]: pam_unix(sshd:session): session opened
for user news by (uid=0)

Back in the ssh session on apache, the following output indicates the
manual authentication works fine:

receiving incremental file list
delta-transmission enabled
testfile
total: matches=0  hash_hits=0  false_alarms=0 data=0

sent 14 bytes  received 108 bytes  1.43 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
news@apache:~/.ssh$

The tail of /var/log/auth.log on inn2 acknowledges:

Aug  3 22:41:00 inn2 sshd[947]: pam_unix(sshd:session): session closed
for user news

It works fine providing I manually enter a password. Of course that is
impossible to do with a cron job running in the middle of the night.

I also do not understand the report "Authentication refused: bad
ownership or modes for directory /var/spool/news" in the tail of the
auth.log of sshd on inn2. There are no improper ownerships nor
permissions. If there were, the manual authentication would fail.

It appears this is acting like the cart before the horse. IOW, it is
wanting read access to /var/log/news/.ssh/authorized_keys to determine
the encrypted password -- which is required to allow access to the same
directory and file!

Debian 5.0.1
OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007
rsync version 3.0.3 protocol version 30

I've fought this for the past three days, so any ideas will be appreciated.


-- 
John
Re: Authentication for rsync over ssh failing
#81738
Author: Ray Banana
Date: Tue, 04 Aug 2009 05:44
32 lines
2499 bytes
Thus spake "John F. Morse" <john@example.invalid>
 
> opening connection using: ssh -i /var/spool/news/.ssh/authorized_keys -l
> news inn2 rsync --server --sender -vvnlogDtprze.iL .
> /var/spool/news/testfile
> A tail of /var/log/auth.log on inn2 shows the following:
> Aug  3 22:39:36 inn2 sshd[947]: Authentication refused: bad ownership or
> modes for directory /var/spool/news
[...]
> I also do not understand the report "Authentication refused: bad
> ownership or modes for directory /var/spool/news" in the tail of the
> auth.log of sshd on inn2. There are no improper ownerships nor
> permissions. 

Please check the permissions for your .ssh directory and authorized_keys
file. They should be 700 for the .ssh directory and 600 for the
authorized_keys file.

> If there were, the manual authentication would fail.

As the manual authentication does not use the .ssh/ directory, your
assumption is wrong. Your manual authentication uses pam_unix.

http://sial.org/howto/openssh/publickey-auth/problems/

And, of course, this problem is not related to news.software.*nntp*

hth

-- 
Time flies like an arrow, fruit flies like a Banana.
http://www.eternal-september.org
Re: Authentication for rsync over ssh failing
#81740
Author: John F. Morse
Date: Tue, 04 Aug 2009 06:46
56 lines
2897 bytes
Ray Banana wrote:
> Thus spake "John F. Morse" <john@example.invalid>
>  
>   
>> opening connection using: ssh -i /var/spool/news/.ssh/authorized_keys -l
>> news inn2 rsync --server --sender -vvnlogDtprze.iL .
>> /var/spool/news/testfile
>> A tail of /var/log/auth.log on inn2 shows the following:
>> Aug  3 22:39:36 inn2 sshd[947]: Authentication refused: bad ownership or
>> modes for directory /var/spool/news
>>     
> [...]
>   
>> I also do not understand the report "Authentication refused: bad
>> ownership or modes for directory /var/spool/news" in the tail of the
>> auth.log of sshd on inn2. There are no improper ownerships nor
>> permissions. 
>>     
>
> Please check the permissions for your .ssh directory and authorized_keys
> file. They should be 700 for the .ssh directory and 600 for the
> authorized_keys file.
>   


As I mentioned at the end of that paragraph, "There are no improper
ownerships nor permissions." This is the first thing that I checked.

drwx------  2 news news   136 2009-08-03 23:46 .ssh

-rw-------  1 news news  395 2009-08-03 20:09 authorized_keys


>> If there were, the manual authentication would fail.
>>     
>
> As the manual authentication does not use the .ssh/ directory, your
> assumption is wrong. Your manual authentication uses pam_unix.
>   


I was referring to ownership and access rights to the directories and
files. If they are improper, a manual rsync/scp would likely fail, but
it doesn't.


> http://sial.org/howto/openssh/publickey-auth/problems/
>
> And, of course, this problem is not related to news.software.*nntp*
>   

It certainly is, if you consider I cannot move the INN status files. ;-)


-- 
John
Re: Authentication for rsync over ssh failing
#81741
Author: Ray Banana
Date: Tue, 04 Aug 2009 06:58
13 lines
1905 bytes
Thus spake "John F. Morse" <john@example.invalid>
 
> As I mentioned at the end of that paragraph, "There are no improper
> ownerships nor permissions." This is the first thing that I checked.
> drwx------  2 news news   136 2009-08-03 23:46 .ssh
> -rw-------  1 news news  395 2009-08-03 20:09 authorized_keys

Can you try ssh -v, as it will give you lots of debug information that
might shed some light on the cause of this problem?

-- 
Time flies like an arrow, fruit flies like a Banana.
http://www.eternal-september.org
Re: Authentication for rsync over ssh failing
#81739
Author: Alexander Bartolich
Date: Tue, 04 Aug 2009 07:39
28 lines
2531 bytes
John F. Morse wrote:
> [...]
> As I mentioned at the end of that paragraph, "There are no improper
> ownerships nor permissions." This is the first thing that I checked.

man sshd
# ~/.ssh/authorized_keys
#
# Lists the public keys (RSA/DSA) that can be used for logging in as
# this user. The format of this file is described above. The content
# of the file is not highly sensitive, but the recommended permissions
# are read/write for the user, and not accessible by others.
#
# If this file, the ~/.ssh directory, or the user's home directory are
# writable by other users, then the file could be modified or replaced
# by unauthorized users. In this case, sshd will not allow it to be
# used unless the StrictModes option has been set to "no".
# The recommended permissions can be set by executing
# "chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys".

My recommendation: Don't mess with user "news".
Instead create another user and add it to group "news".

-- 
Brüder, in die Tonne die Freiheit,
Brüder, ein Stoppschild davor.
Egal was die Schwarzen Verlangen
Rufen wir: Ja! Brav im Chor.
Re: Authentication for rsync over ssh failing
#81742
Author: John F. Morse
Date: Tue, 04 Aug 2009 20:49
211 lines
10307 bytes
Ray Banana wrote:
> Thus spake "John F. Morse" <john@example.invalid>
>  
>   
>> As I mentioned at the end of that paragraph, "There are no improper
>> ownerships nor permissions." This is the first thing that I checked.
>> drwx------  2 news news   136 2009-08-03 23:46 .ssh
>> -rw-------  1 news news  395 2009-08-03 20:09 authorized_keys
>>     
>
> Can you try ssh -v, as it will give you lots of debug information that
> might shed some light on the cause of this problem?
>   


That works.

------------------------------------------------------------------------

news@apache:~/.ssh$ ssh -v inn2
OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to inn2 [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /var/spool/news/.ssh/identity type -1
debug1: identity file /var/spool/news/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /var/spool/news/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version
OpenSSH_5.1p1 Debian-5
debug1: match: OpenSSH_5.1p1 Debian-5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-5
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'inn2' is known and matches the RSA host key.
debug1: Found key in /var/spool/news/.ssh/known_hosts:7
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /var/spool/news/.ssh/identity
debug1: Offering public key: /var/spool/news/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Linux inn2 2.6.26-2-486 #1 Sun Jun 21 04:15:19 UTC 2009 i586

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Jul  5 10:06:28 2009 from n100.xanadu-bbs.net
news@inn2:~$

------------------------------------------------------------------------

But this doesn't work (here using two rsync -v verbose options for
additional debugging output):

news@apache:~/.ssh$ rsync -avvzn -e "ssh -i
/var/spool/news/.ssh/authorized_keys" news@inn2:/var/spool/news/testfile
/var/spool/news/.ssh/
opening connection using: ssh -i /var/spool/news/.ssh/authorized_keys -l
news inn2 rsync --server --sender -vvnlogDtprze.iL .
/var/spool/news/testfile
Enter passphrase for key '/var/spool/news/.ssh/authorized_keys':
news@inn2's password:
receiving incremental file list
delta-transmission enabled
testfile
total: matches=0  hash_hits=0  false_alarms=0 data=0

sent 14 bytes  received 108 bytes  18.77 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
news@apache:~/.ssh$

------------------------------------------------------------------------

One caveat that bothers me from what I remember during my first
encounter with rsync a few years ago, is where it is stated rsync could
not copy files between two remotes. The rsync(1) man page states:

GENERAL
       Rsync  copies  files  either to or from a remote host, or locally
on the current host
       (it does not support copying files between two remote hosts).

I understand this to mean I cannot run rsync on computer A to copy files
from computer B to computer C, such as:

"news@A:~/.ssh rsync -avz news@B:/var/spool/news/testfile
news@C:/var/spool/news/testfile"

I do not think the restriction applies when I connect, via ssh, from
computer A to computer C, and run rsync on computer C to connect to
computer B to copy files from B to C.

But there may be some security built into rsync that is prohibiting
copying when the controlling is from a remote PC, in this case an
incoming ssh session from computer A. I don't know.

If you (or any other reader) can verify that it is indeed possible to
rsync from a remote computer, while running rsync in a ssh session from
a third computer, then I can go to the Apache server, plug in a monitor
and keyboard, and try the test there.

If this is indeed the problem, then after a successful test (from apache
with a monitor and keyboard), the rsync should be able to work with a
cron job on apache (since that would be "local").

To further back up my belief that ownerships, permissions, and the RSA
keys are all correct, here is a successful rcp/scp transfer (with -v)
from inn2 running on apache, via a remote ssh session:

------------------------------------------------------------------------

news@apache:~$ rcp news@inn2:/var/spool/news/testfile .
testfile                                                                         
100%    0     0.0KB/s   00:00   
news@apache:~$ rcp -v news@inn2:/var/spool/news/testfile .
Executing: program /usr/bin/ssh host inn2, user news, command scp -v -f
/var/spool/news/testfile
OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to inn2 [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /var/spool/news/.ssh/identity type -1
debug1: identity file /var/spool/news/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /var/spool/news/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version
OpenSSH_5.1p1 Debian-5
debug1: match: OpenSSH_5.1p1 Debian-5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-5
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'inn2' is known and matches the RSA host key.
debug1: Found key in /var/spool/news/.ssh/known_hosts:7
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /var/spool/news/.ssh/identity
debug1: Offering public key: /var/spool/news/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -f /var/spool/news/testfile
Sending file modes: C0644 0 testfile
Sink: C0644 0 testfile
testfile                                                                         
100%    0     0.0KB/s   00:00   
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2352, received 2408 bytes, in 0.1 seconds
Bytes per second: sent 19075.1, received 19529.3
debug1: Exit status 0
news@apache:~$

------------------------------------------------------------------------

The above worked great.

It seems that rsync is the problem, and rsync is needed because I only
want to copy the new daily report status files each day, not the
complete archive.


-- 
John
Re: Authentication for rsync over ssh failing
#81743
Author: John F. Morse
Date: Tue, 04 Aug 2009 20:52
34 lines
2456 bytes
Alexander Bartolich wrote:
> John F. Morse wrote:
>   
>> [...]
>> As I mentioned at the end of that paragraph, "There are no improper
>> ownerships nor permissions." This is the first thing that I checked.
>>     
>
> man sshd
> # ~/.ssh/authorized_keys
> #
> # Lists the public keys (RSA/DSA) that can be used for logging in as
> # this user. The format of this file is described above. The content
> # of the file is not highly sensitive, but the recommended permissions
> # are read/write for the user, and not accessible by others.
> #
> # If this file, the ~/.ssh directory, or the user's home directory are
> # writable by other users, then the file could be modified or replaced
> # by unauthorized users. In this case, sshd will not allow it to be
> # used unless the StrictModes option has been set to "no".
> # The recommended permissions can be set by executing
> # "chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys".
>   


Thanks Alexander, but that was done days ago.

Also using 755 instead of 700 was suggested on one Webpage for testing.
However that is not good security, and even causes a warning message
about too loose security.


-- 
John
Re: Authentication for rsync over ssh failing
#81744
Author: John F. Morse
Date: Tue, 04 Aug 2009 21:07
50 lines
2998 bytes
Alexander Bartolich wrote:
> John F. Morse wrote:
>   
>> [...]
>> As I mentioned at the end of that paragraph, "There are no improper
>> ownerships nor permissions." This is the first thing that I checked.
>>     
>
> man sshd
> # ~/.ssh/authorized_keys
> #
> # Lists the public keys (RSA/DSA) that can be used for logging in as
> # this user. The format of this file is described above. The content
> # of the file is not highly sensitive, but the recommended permissions
> # are read/write for the user, and not accessible by others.
> #
> # If this file, the ~/.ssh directory, or the user's home directory are
> # writable by other users, then the file could be modified or replaced
> # by unauthorized users. In this case, sshd will not allow it to be
> # used unless the StrictModes option has been set to "no".
> # The recommended permissions can be set by executing
> # "chmod go-w ~/ ~/.ssh ~/.ssh/authorized_keys".
>
> My recommendation: Don't mess with user "news".
> Instead create another user and add it to group "news".
>   


Hi, Alexander.

I fail to see where that would be a solution. It would give the new user
the same modes as user news, the owner of the group news.

It would also run contrary to the "chmod go-w" idea, because the files
are actually 600 or 700 for more security, eliminating all group and
other access.

During testing I did loosen the access up to 777 and still was not able
to authenticate with an RSA key using rsync (but ssh and rcp/scp did work).

See my lengthy reply to Ray, and especially the area where I suspect
rsync may be locking me out because I'm running this remote rsync test
via ssh.

Perhaps you use rsync remotely with RSA/DSA key authentication (not
passwords)?


-- 
John
Re: Authentication for rsync over ssh failing
#81745
Author: Alexander Bartolich
Date: Tue, 04 Aug 2009 21:54
62 lines
3812 bytes
John F. Morse schrieb:
> Alexander Bartolich wrote:
>> [ StrictModes yes ]
>> My recommendation: Don't mess with user "news".
>> Instead create another user and add it to group "news".
>
> I fail to see where that would be a solution. It would give the new user
> the same modes as user news, the owner of the group news.

On my system ~news is /var/spool/news

$ ls -lad /var/spool/news
drwxrwxr-x 10 news news 4096 2009-07-29 21:11 /var/spool/news/

As you see group "news" has write permissions to ~news. If sshd is
configured to "StrictModes yes" (the default) then it will not allow
public key login as user "news". Changing the permissions of ~news
can have unintended side effects, though.

The alternative is to create another user, let's call it "backup".
Permissions of directories ~backup and ~backup/.ssh are set to 0700.
Since nobody else uses these directories that has no side effects.

To perform the copy after login user "backup" needs read access to
the requested files. A secure way to achieve that is to make the
files group-readable and add user "backup" to that group.

> It would also run contrary to the "chmod go-w" idea, because the files
> are actually 600 or 700 for more security, eliminating all group and
> other access.

So, your ~news is actually set to 0700?
And all files in it are set to 0600?

Anyway, "more security" is a vague term. With the group based setup
you can give programs only read-access, and nothing more. Bugs or
exploits in those programs then cannot be used to harm user "news".

> During testing I did loosen the access up to 777 and still was not able
> to authenticate with an RSA key using rsync (but ssh and rcp/scp did work).

"still not able" is a funny way to put it.

> See my lengthy reply to Ray, and especially the area where I suspect
> rsync may be locking me out because I'm running this remote rsync test
> via ssh.
>
> Perhaps you use rsync remotely with RSA/DSA key authentication
> (not passwords)?

Sorry, but I understand less and less what you are saying.

You started the thread with 
# I have the proper keys created ("ssh-keygen -t rsa") with no
# passphrase.
and now you say that you are not using public keys?

-- 
Brüder, in die Tonne die Freiheit,
Brüder, ein Stoppschild davor.
Egal was die Schwarzen Verlangen
Rufen wir: Ja! Brav im Chor.
Re: Authentication for rsync over ssh failing
#81746
Author: Alexander Bartolich
Date: Tue, 04 Aug 2009 22:07
19 lines
1928 bytes
John F. Morse schrieb:
> [...]
> But this doesn't work (here using two rsync -v verbose options for
> additional debugging output):
>
> news@apache:~/.ssh$ rsync -avvzn -e "ssh -i
> /var/spool/news/.ssh/authorized_keys" news@inn2:/var/spool/news/testfile
> /var/spool/news/.ssh/

Why do you want to copy directory
  /var/spool/news/testfile
from news@inn2 to local directory
  /var/spool/news/.ssh/
?

Especially since local /var/spool/news/.ssh/ holds the private key
required for ssh login.

-- 
Re: Authentication for rsync over ssh failing
#81747
Author: John F. Morse
Date: Wed, 05 Aug 2009 00:14
124 lines
5207 bytes
Alexander Bartolich wrote:
> John F. Morse schrieb:
>   
>> Alexander Bartolich wrote:
>>     
>>> [ StrictModes yes ]
>>> My recommendation: Don't mess with user "news".
>>> Instead create another user and add it to group "news".
>>>       
>> I fail to see where that would be a solution. It would give the new user
>> the same modes as user news, the owner of the group news.
>>     
>
> On my system ~news is /var/spool/news
>
> $ ls -lad /var/spool/news
> drwxrwxr-x 10 news news 4096 2009-07-29 21:11 /var/spool/news/
>
> As you see group "news" has write permissions to ~news. If sshd is
> configured to "StrictModes yes" (the default) then it will not allow
> public key login as user "news". Changing the permissions of ~news
> can have unintended side effects, though.
>   


But I am accessing when using ssh and scp.


> The alternative is to create another user, let's call it "backup".
> Permissions of directories ~backup and ~backup/.ssh are set to 0700.
> Since nobody else uses these directories that has no side effects.
>
> To perform the copy after login user "backup" needs read access to
> the requested files. A secure way to achieve that is to make the
> files group-readable and add user "backup" to that group.
>
>   
>> It would also run contrary to the "chmod go-w" idea, because the files
>> are actually 600 or 700 for more security, eliminating all group and
>> other access.
>>     
>
> So, your ~news is actually set to 0700?
> And all files in it are set to 0600?
>   


Yes, I've stated that several times.

What I am using is what I have found on various Websites:

http://troy.jdmz.net/rsync/index.html
http://www.scrounge.org/linux/rsync.html
http://kimmo.suominen.com/docs/ssh
http://www.rootprompt.org/article.php3?article=8976
http://sial.org/howto/rsync
http://sial.org/howto/openssh/publickey-auth/problems
https://help.ubuntu.com/community/rsync
http://www.debianhelp.co.uk/rsync.htm
http://everythinglinux.org/rsync
http://www.fredshack.com/docs/rsync.html
http://www.perihel.at/3/index.html#rsync
http://rsync.samba.org
http://www.samba.org/rsync/documentation.html
http://samba.anu.edu.au/rsync/examples.html
http://www.mikerubel.org/computers/rsync_snapshots
http://linux.about.com/library/cmd/blcmdl1_rsync.htm
http://en.wikipedia.org/wiki/Rsync

All of the above say basically the same thing when addressing my situation.

I guarantee you, I've read and tried different methods until I'm blue in
the face.



> Anyway, "more security" is a vague term. With the group based setup
> you can give programs only read-access, and nothing more. Bugs or
> exploits in those programs then cannot be used to harm user "news".
>   


I'm not worried about the term. My goal (focus) is to get rsync working
unattended.


>> During testing I did loosen the access up to 777 and still was not able
>> to authenticate with an RSA key using rsync (but ssh and rcp/scp did work).
>>     
>
> "still not able" is a funny way to put it.
>   


Why do you think that?


>> See my lengthy reply to Ray, and especially the area where I suspect
>> rsync may be locking me out because I'm running this remote rsync test
>> via ssh.
>>
>> Perhaps you use rsync remotely with RSA/DSA key authentication
>> (not passwords)?
>>     
>
> Sorry, but I understand less and less what you are saying.
>
> You started the thread with 
> # I have the proper keys created ("ssh-keygen -t rsa") with no
> # passphrase.
> and now you say that you are not using public keys?


Where do you see I stated that I am not using public keys?

I think my extremely-lengthy messages have all that is needed in them to
understand what is happening.

I posted the commands, followed by the  results. I am not the one
"saying" these, but  Debian. ;-)


-- 
John
Re: Authentication for rsync over ssh failing
#81749
Author: John F. Morse
Date: Wed, 05 Aug 2009 00:16
32 lines
2083 bytes
Alexander Bartolich wrote:
> John F. Morse schrieb:
>   
>> [...]
>> But this doesn't work (here using two rsync -v verbose options for
>> additional debugging output):
>>
>> news@apache:~/.ssh$ rsync -avvzn -e "ssh -i
>> /var/spool/news/.ssh/authorized_keys" news@inn2:/var/spool/news/testfile
>> /var/spool/news/.ssh/
>>     
>
> Why do you want to copy directory
>   /var/spool/news/testfile
> from news@inn2 to local directory
>   /var/spool/news/.ssh/
> ?
>
> Especially since local /var/spool/news/.ssh/ holds the private key
> required for ssh login.
>   


I don't. That is only an example.

Remove the .ssh/ if it is easier to understand.

The file "testfile" is irrelevant, as is where it goes.


-- 
John
Re: Authentication for rsync over ssh failing
#81750
Author: John F. Morse
Date: Wed, 05 Aug 2009 01:50
43 lines
2932 bytes
John F. Morse wrote:

<snip>

> One caveat that bothers me from what I remember during my first
> encounter with rsync a few years ago, is where it is stated rsync could
> not copy files between two remotes. The rsync(1) man page states:
>
> GENERAL
>        Rsync  copies  files  either to or from a remote host, or locally
> on the current host
>        (it does not support copying files between two remote hosts).
>
> I understand this to mean I cannot run rsync on computer A to copy files
> from computer B to computer C, such as:
>
> "news@A:~/.ssh rsync -avz news@B:/var/spool/news/testfile
> news@C:/var/spool/news/testfile"
>
> I do not think the restriction applies when I connect, via ssh, from
> computer A to computer C, and run rsync on computer C to connect to
> computer B to copy files from B to C.
>
> But there may be some security built into rsync that is prohibiting
> copying when the controlling is from a remote PC, in this case an
> incoming ssh session from computer A. I don't know.
>
> If you (or any other reader) can verify that it is indeed possible to
> rsync from a remote computer, while running rsync in a ssh session from
> a third computer, then I can go to the Apache server, plug in a monitor
> and keyboard, and try the test there.
>
> If this is indeed the problem, then after a successful test (from apache
> with a monitor and keyboard), the rsync should be able to work with a
> cron job on apache (since that would be "local").


The test mentioned above, from a local console, indicates that the
problem still exists.


-- 
John
Re: Authentication for rsync over ssh failing
#81752
Author: Julien ÉLIE
Date: Wed, 05 Aug 2009 06:09
23 lines
2322 bytes
Hi John,

>>> During testing I did loosen the access up to 777 and still was not able
>>> to authenticate with an RSA key using rsync (but ssh and rcp/scp did work).
>>
>> "still not able" is a funny way to put it.
>
> Why do you think that?

Because the more the directory has rights, the less you will be able to connect.

As Alexander told you, the group should not be able to *write* to the directory.

Another thing that may work is to change the home path of the news user. Say
/home/news, with 700 access and your keys in /home/news/.ssh; I think you will
then be able to connect with an exchange of keys.

-- 
Julien ÉLIE

« Passion is inversely proportional to the amount of real information available. »
  (Benford's law) 
Re: Authentication for rsync over ssh failing
#81751
Author: John F. Morse
Date: Wed, 05 Aug 2009 07:58
153 lines
5618 bytes
Julien ÉLIE wrote:
> Hi John,
>
>>>> During testing I did loosen the access up to 777 and still was not
>>>> able
>>>> to authenticate with an RSA key using rsync (but ssh and rcp/scp
>>>> did work).
>>>
>>> "still not able" is a funny way to put it.
>>
>> Why do you think that?
>
> Because the more the directory has rights, the less you will be able
> to connect.
>
> As Alexander told you, the group should not be able to *write* to the
> directory.
>
> Another thing that may work is to change the home path of the news
> user. Say
> /home/news, with 700 access and your keys in /home/news/.ssh; I think
> you will
> then be able to connect with an exchange of keys.
>


Hi Julien.

The chmod 777 was a troubleshooting suggestion found on one of the Web
pages from those links I posted.

I didn't leave the mode at 777, but only tested it there as the Web page
suggested.

The mode is 600 for the files, and 700 for the directory.

Now, how could someone change the home path of user news when the INN
server requires user news to (normally) be at /var/spool/news ? I do
have an INN testing server running on the "apache" server. Now I can
install the Apache2 Webserver on one of the production INN boxes, and
shut down the "apache" server test box to save electricity. ;-)

Anyway, I got it working fine by educated guesses, trial and error, and
doing something that I didn't find on any of those Websites.

Instead of using this command which is shown on those Websites:

rsync -avz -e "ssh -i /var/spool/news/.ssh/authorized_keys"
news@inn2:/var/www/inn2 /var/www

On the "apache" server I simply used:

rsync -avz news@inn2:/var/www/news2 /var/www

The "inn2" server authenticated properly and sent only those files that
were new (or had changed).

Why those HOWTOs all had the "-e 'ssh -i
/var/spool/news/.ssh/authorized_keys'" in the command is anyone's guess
(possibly some Red Hat stuff).

I found that the required files, directories, ownerships and permissions
are:


On the "apache" server:

news@apache:/var/spool/news$ ls -al

drwx------  2 news news   104 2009-08-04 21:10 .ssh

news@apache:~/.ssh$ ls -al

-rw-------  1 news news 1675 2009-08-04 02:27 id_rsa
-rw-r--r--  1 news news 5402 2009-08-04 22:14 known_hosts


On the "inn2" server:

news@inn2:~$ ls -al

drwx------  2 news news   112 2009-08-04 21:07 .ssh

news@inn2:~/.ssh$ ls -al

-rw-------  1 news news  395 2009-08-03 20:09 authorized_keys
-rw-r--r--  1 news news 4420 2009-08-04 02:02 known_hosts


So simple that I'm surprised someone didn't catch this. (Of course it
took me three days!)


Back on "apache," in news' home directory, I set up the cron script:

news@apache:~$ ls -al

drwxr-xr-x  2 news news   144 2009-08-04 22:13 cron

[I could probably lock the above down with a chmod 700]


news@apache:~/cron$ ls -al

-rwxr--r--  1 news news  59 2009-08-04 21:36 rsync-inn2

[This could probably be a chmod 600]


news@apache:~/cron$ cat rsync-inn2

#!/bin/sh

rsync -avz news@inn2:/var/www/inn2 /var/www


Finally, the cron job parts:

news@apache:/etc/cron.d$ ls -al

-rw-r--r--  1 root root 1614 2009-08-04 22:11 inn2

news@apache:/etc/cron.d$ cat inn2

2 1     * * *   news    /var/spool/news/cron/rsync-inn2


That is very simple, and works slicker than snot. ;-)

I discovered that none of the suggestions on the Web sites worked as
written, nor any of the suggestions in this newsgroup, with the single
exception which Ray Banana supplied:

"Can you try ssh -v, as it will give you lots of debug information that might shed some light on the cause of this problem?"


That told me that the RSA key access was indeed working, since I could
ssh and also scp/rcp without problems or the need to type in a password.
It also told me to look at rsync for the problem.

I found the problem was the "-e 'ssh -i
/var/spool/news/.ssh/authorized_keys'" which failed because no access
was yet available to that /var/spool/news/.ssh/authorized_keys file to
provide any access!

That is the classic "cart-before-the-horse" which I suspected and
mentioned in my original post.

Thanks for your help, Julien.


-- 
John
Re: Authentication for rsync over ssh failing
#81753
Author: Julien ÉLIE
Date: Wed, 05 Aug 2009 15:58
20 lines
2185 bytes
Hi John,

Glad to know you have solved your issue!


> Now, how could someone change the home path of user news when the INN
> server requires user news to (normally) be at /var/spool/news ?

There is no requirement for the home directory as it is set up
in your shell.
You can put something else; for instance, pullnews will search for
a file named ~/.pullnews (in the home directory seen by your shell,
that is to say $ENV{HOME}/.pullnews, and not in <pathnews> as set
in inn.conf).

-- 
Julien ÉLIE

« On ne naît pas femme, on le devient. » (Simone de Beauvoir)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads