Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-31-2006, 09:18 PM
|
#1
|
LQ Newbie
Registered: Jan 2006
Posts: 4
Rep:
|
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
|
|
|
01-31-2006, 10:01 PM
|
#2
|
Member
Registered: Apr 2003
Location: Vancouver, BC
Distribution: Slackware, Ubuntu
Posts: 558
Rep:
|
|
|
|
02-01-2006, 12:13 AM
|
#3
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
02-01-2006, 06:49 AM
|
#4
|
Moderator
Registered: May 2001
Posts: 29,415
|
...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?
|
|
|
02-01-2006, 09:24 PM
|
#5
|
LQ Newbie
Registered: Jan 2006
Posts: 4
Original Poster
Rep:
|
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
|
|
|
02-04-2006, 03:00 AM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
All times are GMT -5. The time now is 06:43 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|