LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-27-2015, 08:45 AM   #1
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Rep: Reputation: Disabled
Shared Key Security?


I set up shared keys (no passphrase for cron automation) on 2 servers to backup home directories from one to the other.

Server A is the backup storage.

Server B is the sender of of the files to Server A.

My question is:
IF Server B is hacked, what are the security issues to Server A?


Thanks to all in advance.
 
Old 06-27-2015, 09:03 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
If server B gets cracked and the intruders find the keys to A, then they can get into A with whatever permissions you have granted the account that uses the keys. So at the minimum it is a good idea to restrict what the keys can do. See "command=" in the manual page for sshd(8) Better, would be to also use a proper passphrase on the key. You can use an agent on B to hold the key and have the cron script access the agent. Then you have to enter the passphrase only when B gets rebooted, at least in theory.
 
1 members found this post helpful.
Old 06-27-2015, 10:41 AM   #3
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
I have never been able to get rsync to run between "chroot jailed" users. That would help a lot.
 
Old 06-27-2015, 10:47 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
chroot with rsync might be quite hard. However, you can lock the keys down quite a bit. If you are doing the exact same rsync command each and every time, rsync's options can be made part of the public key over on the destination (A) . Then if the source machine (B) gets cracked, all the intruders could do would be to make an new transfer.
 
Old 06-27-2015, 11:10 AM   #5
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
The rsync command is always the same; /usr/bin/backup

With my limited Linux abilities, I have NO clue how to do what you just said.

the rsync command is this cron jobbed (I hope; it worked manually last night.):

#!/bin/bash
rsync -avz -e ssh /home/* root@00.00.00.00:/home/backup

echo "All done with Backup to `hostname` on `date`" |mailx -s "Backup finished to `hostname`" myemail@address.com &

=======================
Things in place already:

1. user on Server B has one 5 minute window to make the connection per week on Server A.

2. I thought about this but do not know if it is a good or very bad idea. Move the Keys on Server B to a non-shell account once the 5 minute window is up ????

Last edited by HardenedCriminal; 06-27-2015 at 02:07 PM.
 
Old 06-27-2015, 12:45 PM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
If you have this:

Code:
rsync -avz -e ssh /home/* root@aa.bb.cc.dd:/home/backup/
Then you can run it manually with the SSH client in verbose mode:

Code:
rsync -avz -e "ssh -v" /home/* root@aa.bb.cc.dd:/home/backup/
And you will see a line approximately like this:

Code:
debug1: Sending command: rsync --server -logDtprze.iLs . /home/backup/
Then on the server in the authorized_keys file, you can preface your key with command="..." something approximately like this, but with your own public key:

Code:
command="/usr/bin/rsync --server -logDtprze.iLs . /home/backup/" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/ez/409gxNehfcNV5Bsz...
And since you are using root you should have PermitRootLogin without-password or PermitRootLogin forced-commands-only It would be best if you could do without root on the remote machine and use a normal user there.
 
1 members found this post helpful.
Old 06-27-2015, 01:06 PM   #7
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
I really wish when Linux programs are done they would update the "man pages" later. Like I saw in a post --time-limit but not anything in the man pages for rsync; as of yet I have not tried it.

I saw the command at "rsync.samba.org" but had no idea how to do the "command" line goo. They lost me in the following discussion.

Thanks I am trying now.

These are HOME directories so either ROOT or a user that is chown user.root; neither of them do I really want to add access on either server but this is a much lesser evil than hoping users will ever back up anything even once in a very long time.
 
Old 06-27-2015, 01:23 PM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Your distro might have 'timeout' which would be used in front of the program to be timed. It will kill the process with a TERM signal if it is still running when the time runs out.

Code:
timeout 20m rsync -avz -e 'ssh -i ...
 
1 members found this post helpful.
Old 06-27-2015, 02:10 PM   #9
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
We are getting there but NOT there yet.

I put in the "command=" line and it works great... to stop ssh to 00.00.00.00

but if I ssh to hostname.com (server A) I can get right on in.
 
Old 06-27-2015, 02:12 PM   #10
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
Yes thank you.

TIMEOUT is there.
 
Old 06-27-2015, 02:15 PM   #11
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Did you set PermitRootLogin forced-commands-only in sshd_config on machine A?
You should then still be able to ssh in as a regular user but not as root unless the command is set inside authorized_keys.
 
1 members found this post helpful.
Old 06-27-2015, 02:31 PM   #12
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
Yes. It is there but when I saw this:

Are you sure you want to continue connecting (yes/no)? yes

I didn't go the rest of the way to find a black hole.
 
Old 06-27-2015, 02:34 PM   #13
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
I am still going to do my 5 minute interval but this "command=" is great!!

Now if someone could update the documentation in at rsync.samba.org.
 
Old 06-27-2015, 02:52 PM   #14
HardenedCriminal
Member
 
Registered: May 2015
Posts: 104

Original Poster
Rep: Reputation: Disabled
I will add this for those who have different SSH port settings:

# Remember HOST & PORT setting in /etc/ssh/ssh_config on Server A (host)
# Host 00.00.00.00
# Port = 000
 
  


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
Risks of VPN with pre-shared key dilettante9 Linux - Security 6 06-17-2015 09:35 AM
shared key vs signed certificate in one use case Skaperen Linux - Security 11 09-21-2012 11:10 PM
wpa_supplicant pre-shared key may be incorrect heluani Linux - Wireless Networking 5 10-21-2009 06:56 PM
Shared key authentication and Putty mpmackenna Linux - Newbie 8 10-25-2007 09:06 AM
Shared Key ssh login only pccdrussell Linux - General 2 10-19-2007 06:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:54 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