Linux - SecurityThis 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.
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.
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.
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.
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 :-)
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.