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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-27-2008, 12:26 AM
|
#1
|
|
Member
Registered: Jun 2007
Posts: 64
Rep:
|
ssh password from a text file
Hi,
I am writing a BASH script which should ssh to a server.
Is there any way such that ssh takes password from a text file so that
my script runs without any human interaction.
Thanks a lot in advance.
|
|
|
|
01-27-2008, 12:45 AM
|
#2
|
|
Member
Registered: Dec 2007
Posts: 32
Rep:
|
this would be very bad practice.
If you want this setup, I would suggest instead using an ssh key without a password. This is also the normal ( accepted/more secure ) way of doing it.
|
|
|
|
01-27-2008, 02:08 AM
|
#3
|
|
Member
Registered: Nov 2005
Location: New Jersey, USA
Distribution: SuSE
Posts: 492
Rep:
|
SSH key is *definitely* the way to go.
This is extremely bad practice, but if you wanted to automate entry of information in an interactive environment, you'd want to use Expect.
|
|
|
|
01-27-2008, 08:09 AM
|
#4
|
|
Moderator
Registered: May 2001
Posts: 24,822
|
Quote:
Originally Posted by overpencil
this would be very bad practice.
If you want this setup, I would suggest instead using an ssh key without a password. This is also the normal ( accepted/more secure ) way of doing it.
|
Agreed. If you go that route make sure you up your logging and restrict access to that account and what tasks that account may perform as much as possible.
|
|
|
|
01-28-2008, 12:37 AM
|
#5
|
|
Member
Registered: Jun 2007
Posts: 64
Original Poster
Rep:
|
I want to do it without using authorized_keys file. I should be able to ssh to any server using this script where my account exists. I am writing this script to run only in my home network where all of our friends work together on linux for expermentation purpose. Just want to save time typing passwords and without using authorized_keys :-)
|
|
|
|
01-30-2008, 06:22 PM
|
#6
|
|
Member
Registered: Sep 2003
Distribution: Ubuntu, Debian Sarge, Mac OS X, FreeBSD
Posts: 45
Rep:
|
Why don't you want to use authorized_keys? You are just going to be reinventing the wheel otherwise.
|
|
|
|
02-13-2008, 11:36 PM
|
#7
|
|
Member
Registered: Jun 2007
Posts: 64
Original Poster
Rep:
|
I am not expected to use this file in my office. Is there anyway the BASH can simulate the entering of password when ssh prompts for a password?
I mean to ask, Can i write a script such that I can detect some program waiting (ssh prompting for input in this case) and simulate the key strokes and an 'Enter' at the end :-) Is such a script possible to write?
|
|
|
|
02-14-2008, 12:36 AM
|
#8
|
|
Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678
Rep: 
|
You could have set up the keys by now
|
|
|
|
02-14-2008, 12:44 AM
|
#9
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
The general answer to your question is to use "expect". Keys are a better way to go.
Also look at the "ssh-agent" program. Using it you will only have to enter your passphrase once. Using authorized-keys with passphrases and agent is the most secure method according to the ssh manpages.
|
|
|
|
02-14-2008, 01:57 AM
|
#10
|
|
Senior Member
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986
Rep:
|
Quote:
Originally Posted by billymayday
You could have set up the keys by now
|
LOLLLLLLLLLLLL 
|
|
|
|
02-21-2008, 03:09 AM
|
#11
|
|
Member
Registered: Jun 2007
Posts: 64
Original Poster
Rep:
|
Thanks a lot to all. I joined only recently here. Otherwise i would have put all keys long before
Yes i'll surely try the ssh-agent
|
|
|
|
02-16-2011, 11:49 AM
|
#12
|
|
LQ Newbie
Registered: Feb 2011
Location: Switzerland & Silicon Valley, USA
Distribution: Ubuntu, CentOS
Posts: 2
Rep:
|
What about sshpass ?
Here I show a simple example:
sshpass -f user.pwd ssh user@hostserver path/command
Where -f indicates that the file contains the password (in this case: user.pwd)
The user@hostserver is the standard item
And the command, if you need to execute one, should be put at the end.
You can find more information here:
SSHPASS Tutorial
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:04 AM.
|
|
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
|
|