LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2009, 02:55 AM   #1
ravibhure
Member
 
Registered: May 2007
Posts: 75

Rep: Reputation: 15
read echo password and login to remote server


How can I access remote server to echo my root password on screen and then read from stdin ,,, any clue or tips on that

echo password | ssh --stdin "root@192.168.19.19"

when I tried it local it give an error
[root@localhost ~]# echo password | ssh --stdin "root@192.168.19.19"
Pseudo-terminal will not be allocated because stdin is not a terminal.
root@192.168.19.19's password:

Last edited by ravibhure; 06-18-2009 at 03:01 AM.
 
Old 06-18-2009, 03:01 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
It is not possible. The main feature of the secure shell SSH is that the traffic is encrypted and give a password in clear text in the command line does not make sense. If you want a passwordless connection, you can use "Public Key Authentication". Use ssh-keygen to create your own private/public key pair and arrange things accordingly to the ssh versions installed on both the client and the server.
 
Old 06-18-2009, 03:02 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Alternatively check out expect if the remote device is not able to use a shared secret, e.g. a router or some such.
 
Old 06-18-2009, 03:10 AM   #4
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
Just remember that commands (normally) are stored, so if you do something like that the root password will be stored in clear text in ~/.bash_history. That is a bad thing. The same applies to scripts with expect. The scripts are also stored in clear text.

The solution I would prefer is to make an expect script which take your password as a argument. Then you add your script to $HISTIGNORE. This is a colon-separated list of patterns that won't be stored in .bash_history. I wouldn't say it's a good solution, but it is a solution if you have to specify the login password from the command-line.
 
Old 06-18-2009, 03:15 AM   #5
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks to you All, to provide this info as soon possible ,Will implement with all your solutions.
 
Old 06-18-2009, 03:28 AM   #6
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
I found a script that did something similar. I modified it a little:
(http://bash.cyberciti.biz/security/e...-login-script/)

Code:
#!/usr/bin/expect -f
# Expect script to supply root/admin password for remote ssh server
# and execute command.
# This script needs three argument to(s) connect to remote server:
# password = Password of remote UNIX server, for root user.
# ipaddr = IP Addreess of remote UNIX server, no hostname
# scriptname = Path to remote script which will execute on remote server
# For example:
#  ./sshlogin.exp password 192.168.1.11
# ------------------------------------------------------------------------
# Copyright (c) 2004 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# set Variables
set password [lrange $argv 0 0]
set ipaddr [lrange $argv 1 1]
set arg1 [lrange $argv 3 3]
set timeout -1

# now connect to remote UNIX box (ipaddr)
spawn ssh root@$ipaddr 

match_max 100000

# Look for passwod prompt
expect "*?assword:*"

# Send password aka $password
send -- "$password\r"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
interact
 
Old 06-19-2009, 08:28 AM   #7
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks Dinithion,
I know about all the facts and usages of "expect" this is quite good script but I have to check some long list parameter on remote server and I have remote server's root password but I dont have any permission to to add my rsa key on remote server, and I have to check 200 servers, so I wrote on script for that but the issue is only for password.

This script only working for single command if you used any option with command then it's hang.
 
Old 06-20-2009, 06:29 AM   #8
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Hello folks
Actually we need to run commands from apache/php to remote server
 
  


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
how login to remote machine with out password? bkcreddy17 Linux - Newbie 2 02-16-2009 04:30 AM
how to read console output from remote server gogoabc Programming 1 01-21-2009 05:01 AM
Bypassing password in remote login Sulman Shah Programming 3 01-17-2007 09:25 AM
remote login no password FC2 dretzloff Linux - Security 1 01-08-2005 05:11 PM
Slackware 2.4.22 remote root login no password jerry950 LinuxQuestions.org Member Success Stories 3 02-09-2004 01:40 PM


All times are GMT -5. The time now is 06:52 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration