LinuxQuestions.org
Help answer threads with 0 replies.
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 06-08-2007, 11:56 PM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 889

Rep: Reputation: 61
SSH/SCP with no password


Hello all,

I'm trying to get my webserver to regularly SCP some files into a back up server at my house. The problem is that it requires a password and I don't want that in my cron script. I have read a plethora of material of RSA authentication and I can't seem to make this happen.

Here are some things I'd like clarified. To do password-less SSH connections I understand there is a two keys made. One for the server, and one for the clients that I wish to allow to SSH in password free. Which key goes to which machine and in which directory does which key sit?

My home server is Ubuntu 6.04 Server edition. My webserver is Fedora Core 4 (its dedicated, i have full root). Please tell me what I need to do make this happen. Thanks so much.
 
Old 06-09-2007, 01:03 AM   #2
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by wh33t
Here are some things I'd like clarified. To do password-less SSH connections I understand there is a two keys made. One for the server, and one for the clients that I wish to allow to SSH in password free. Which key goes to which machine and in which directory does which key sit?
You run "ssh-keygen" to generate a pair of private/public key files. The private key file stays on your main computer. The public key file goes to the remote computer which you'd like to SSH into. The public key file should be appended to the file "authorized_keys," which should be in the ~/.ssh directory. To append your public key file to authorized_keys, you can run the following command, assuming your public key file is "id_rsa.txt" and is located in your $HOME directory. This command should be run on your remote machine. It means the public key file must be copied to it from your local computer.
Code:
$ pwd
/home/daihard
$ cat id_rsa.txt >> ~/.ssh/authorized_keys
 
Old 06-09-2007, 01:07 AM   #3
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 889

Original Poster
Rep: Reputation: 61
And what needs to be enabled on my client ssh_config and my sshd_config on my server?

I swear I've already tried to do exactly what you just said, except I never appended the file.
I just renamed my rsa_id.pub file to authorized_keys in my ~/.ssh/ directory on my webserver instead of cat >>.
 
Old 06-09-2007, 01:58 AM   #4
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by wh33t
And what needs to be enabled on my client ssh_config and my sshd_config on my server?

I swear I've already tried to do exactly what you just said, except I never appended the file.
I just renamed my rsa_id.pub file to authorized_keys in my ~/.ssh/ directory on my webserver instead of cat >>.
I didn't have to do anything to those config files on any of my computers. It may be different with Ubuntu, though. (I use CentOS and Fedora Core.)

You might also want to make sure the permissions of the "~/.ssh" directory and the "~/.ssh/authorized_keys" file are set correctly. They should be set "drwx------" and "-rw-r--r--", respectively.
 
Old 06-09-2007, 02:00 AM   #5
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 889

Original Poster
Rep: Reputation: 61
Why does permissions matter if I'm root on both sides and trying to scp a file as root? Could you please post a dump of your servers /etc/ssh/sshd_config for me. Obviously change any values that might be a security issue./
 
Old 06-09-2007, 02:07 AM   #6
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by wh33t
Why does permissions matter if I'm root on both sides and trying to scp a file as root? Could you please post a dump of your servers /etc/ssh/sshd_config for me. Obviously change any values that might be a security issue./
If I understand correctly, the correct permissions must be set for SSH for security reasons. If .ssh is set so normal users can read its contents, then SSH will not allow you to log in with your passphrase (i.e. key).

Here's the dump of my /etc/ssh/sshd_config.
Code:
Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no

GSSAPIAuthentication yes
GSSAPICleanupCredentials yes

UsePAM yes

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES 
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 
AcceptEnv LC_IDENTIFICATION LC_ALL

X11Forwarding yes

Subsystem	sftp	/usr/libexec/openssh/sftp-server
I removed all comments.
 
Old 06-09-2007, 06:46 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Quote:
Why does permissions matter if I'm root on both sides and trying to scp a file as root?
Enabling any remote root account access is a security risk and that's why root account access is disabled by default. Please understand those risks before dismissing best practices as just another nuisance. If you still want to enable remote root account access at least take appropriate precautions (wrt restrictions *and* auditing). Thanks.
 
Old 06-09-2007, 09:04 AM   #8
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 889

Original Poster
Rep: Reputation: 61
Yes. I understand there are security risks. But if someone really wants to hack either of my machines I'm sure they're getting in. I have chosen to use SCP/SSH instead of ftp as my security practice. Furthermore, Linux can be great but I find it is always sucking away countless hours of my time that I could spend a lot more efficiently. I can't afford to not get this system going and finish the project. Every delay costs me more time and money. When everything is finished and the system seems stable, I will have an expert go in and clean up any unnecessary risks I may have created.

**Edit**
I forgot to say I have chosen root users because I felt it would take less setup than figuring out which of my distro's require which permissions on which authorized_keys file etc. Speaking of which... can anyone clear up what those permissions need to be and a handy command to set them?

I still cannot for the life of me get this to work. I did notice however that at one point I could ssh to my webserver from my backup machine with out a password... however that is the process reversed lol, which is what I don't want. I tried everything in opposites too... *sigh*

Last edited by wh33t; 06-09-2007 at 09:05 AM.
 
Old 06-09-2007, 04:03 PM   #9
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by wh33t
**Edit**
Speaking of which... can anyone clear up what those permissions need to be and a handy command to set them?
http://kmself.home.netcom.com/Linux/FAQs/sshrsakey.html
 
Old 06-09-2007, 05:10 PM   #10
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 889

Original Poster
Rep: Reputation: 61
Ok I finally got it working. I think some of the guides I was reading confused me, or perhaps the people who wrote them are confused themselves. Apparently the PUB key file goes to the server you are sshing into as the authorized key... I thought it was the other way around. PUBLIC would go to the public machines... maybe I think differently lol. Thanks all who offered their advice. I appreciate it.
 
Old 06-09-2007, 09:47 PM   #11
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 14.04 LTS
Posts: 915

Rep: Reputation: 34
Quote:
Originally Posted by wh33t
Apparently the PUB key file goes to the server you are sshing into as the authorized key... I thought it was the other way around. PUBLIC would go to the public machines... maybe I think differently lol. Thanks all who offered their advice. I appreciate it.
That's what I thought I'd written in my first reply, but I could have put it in a confusing manner. In any case, I'm glad you got it working.
 
Old 06-09-2007, 11:38 PM   #12
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 889

Original Poster
Rep: Reputation: 61
LOL well I appreciate the effort. I also messed around with my ubuntu config so much i wasn't sure what was going on. So I reinstalled it and tried it backwards and voila!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
SCP without Password help ignignokt Linux - Networking 3 01-02-2007 11:59 AM
scp without password not reliable joanna Linux - Security 2 12-17-2005 10:23 PM
ssh/scp without password not working Mauline Linux - Security 4 03-30-2005 09:26 PM
scp, don't prompt password!! dlublink Linux - Networking 1 01-03-2005 12:54 PM
scp and no password mikeyt_333 Linux - General 2 03-26-2002 03:33 PM

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

All times are GMT -5. The time now is 06:51 PM.

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