LinuxQuestions.org
Help answer threads with 0 replies.
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 01-31-2006, 09:18 PM   #1
Nikee
LQ Newbie
 
Registered: Jan 2006
Posts: 4

Rep: Reputation: 0
Unhappy ssh running remote commands


Hello,

I have 2 SUSE9 LINUX servers. From the server1 I am executing the following command to the server2.

ssh -l accadm execute.sh

When I run the above command manually, the system is asking for a password. When I enter the password the command is executing fine.

I would like to schedule the above command in a cron job.

How can I execute the above command with out entering the password?

Thank you,
Nikee
 
Old 01-31-2006, 10:01 PM   #2
spurious
Member
 
Registered: Apr 2003
Location: Vancouver, BC
Distribution: Slackware, Ubuntu
Posts: 558

Rep: Reputation: 31
See these articles ssh public key authentication to use ssh without passwords.
 
Old 02-01-2006, 12:13 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
If it is just the password that the shell is asking for, then you may be able to produce an identity file (read only by you or rather the cron job owner) and use the "-i identityfile" option. Another method is to use an ~/ssh/authorized_hosts file. The ssh manpage also mentions using a type of DNS record to establish identity. I'm not familiar with this option myself.

If you use an authorized_hosts file, and maybe even the first method, you may need to regenerate the keys on the target host machine and make sure to hit enter when it asks for the passphrase. This was the reason for asking about whether this was just the password, and not the passphrase that you are entering.
 
Old 02-01-2006, 06:49 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608
...in addition to that you can also link an authorized key with a command to run: see man sshd under command="command". And if you're gonna cronjob it anyway, why not do so on the host itself?
 
Old 02-01-2006, 09:24 PM   #5
Nikee
LQ Newbie
 
Registered: Jan 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Hello All,

I am trying to run a command from a local host onto a remote host server.

This is what I have done:
-------------------------------------------------------------------------
Local Host (accci): user accadm:
/home/accadm:> ssh-keygen -t dsa (enter & enter and created a file)

/home/accadm:> scp id_dsa.pub srmadm@srmci:/home/srmadm/
password: <entered password and file copied successfully>
-------------------------------------------------------------------------
Remote Host (srmci): user srmadm:
/home/srmadm:> cat id_dsa.pub >> .ssh/authorized_keys2
/home/srmadm:> cat id_dsa.pub >> .ssh/authorized_keys
/home/srmadm:> chmod 644 .ssh/authorized_keys2 .ssh/authorized_keys
-------------------------------------------------------------------------

Local Host (accci): user accadm: (Trying logon with out password)

/home/accadm:> ssh srmadm@srmci execute.sh
Password: <System is still asking for password>

I am not sure what I am missing here. Do I need to activate nor switch some settings in order to correct the problem?

I really appreciate your quick response.

Thank you,
Nikee
 
Old 02-04-2006, 03:00 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
The first thing that caught my eye is that you are making your authorized_keys file world readable. On other configuration files, this will make ssh refuse to connect even with a password. I would try at least removing the read bit for "others".

Look in the /etc/ssh_config and /etc/sshd_config files for options that could effect authentication. Options like StrictModes and UsePAM may effect how authentication is handled. StrictModes may even cause ssh to look how the permissions on your home directory is set up. If, for example, your home directory's group ownership is "users" and the group read bit isn't cleared for the ~/.ssh/ directory, anyone ( who is a member of the users group ) can read files in your home directory, and ssh may assume your home directory is insecure.

The /etc/sshd_config file also may contain an option that could change the location of a users authorized_keys file.

I'm not versed enough in PAM or the configuration options of sshd to say any more. The permission settings is the only thing I noticed from your response that might be wrong.

Looking in /etc/pam.d/sshd may be illustrative. ( Or it may make your eyes glaze over, like it did mine. ).

References:
man 5 ssh_config
man 5 sshd_config
man pam_ssh

I hate it when I try to help another user, and end up being more confused myself!

Last edited by jschiwal; 02-04-2006 at 03:02 AM.
 
  


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
Running remote application through SSH tuananhbirm Linux - General 1 11-15-2005 02:42 AM
execute multiple ssh remote commands tom221 Linux - Newbie 2 01-28-2005 01:00 PM
Running commands over ssh iago Programming 8 11-28-2004 12:13 PM
remote ssh commands on multiple hosts evilchild Linux - Software 6 08-12-2004 10:48 PM
running commands automatically via SSH tpfraz Linux - General 1 02-13-2004 09:12 AM

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

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