LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 11-04-2007, 11:19 PM   #1
harishkrishnan
LQ Newbie
 
Registered: Apr 2006
Posts: 8

Rep: Reputation: 0
SSH connection to remote machine...


Hi All,

I have a question on SSH...
If we do an ssh connection to a remote linux machine, it will ask for a password. Once password is entered, we will be able to login...

Ex: ssh root@<IP_Addr>
password:

So, what iam looking for is, i should be able to pass the password from the script or a single command. The user should not be asked for password.

I tried the following options....but it din't work.

- echo <passwd> | ssh root@<IP Addr>
- ssh root@<IP Addr> --stdin <passwd>

Kindly help me on this...

Note: I know about sharing the keys and avoid asking password itself.
 
Old 11-05-2007, 12:26 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
You can use authentication based on a key pair. Edit the sshd config and set the password authentication to no (as shown below).

Code:
# To disable tunneled clear text passwords, change to no here!
#WimS
PasswordAuthentication no
#PasswordAuthentication yes
Next the user needs to generate a keypair.

Code:
wim@btd-techweb01:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wim/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wim/.ssh/id_rsa.
Your public key has been saved in /home/wim/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx wim@btd-techweb01
The private key needs to be carried to the clients that need access. I copied it to a memory stick so I can access the server from 'any' location; no memory stick, no access.

If you omit the passphrase, the user will not be prompted for the passphrase.

Some other advise:
  • limit the users in the config; if user A does not need access, config the server so he/she can not use SSH
  • in general you should not use direct root access; access the server as a normal user and next su to root or use (sudo to elevate privileges). Everybody knows that there is a root user and will try to hack that account.

Last edited by Wim Sturkenboom; 11-05-2007 at 12:28 AM.
 
Old 11-05-2007, 12:59 AM   #3
complich8
Member
 
Registered: Oct 2007
Distribution: rhel, fedora, gentoo, ubuntu, freebsd
Posts: 104

Rep: Reputation: 15
ssh won't read a password from a piped stdin.

If you're really dedicated to not using a key pair, consider writing an expect script to do what you want.

ssh-agent may also be a viable answer.

Last edited by complich8; 11-05-2007 at 01:02 AM.
 
Old 11-06-2007, 08:58 PM   #4
harishkrishnan
LQ Newbie
 
Registered: Apr 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks Wim & Complich...

But tell me, does this Key pair work for Solaris also ? .i.e from local Linux box, i have to execute commands of remote Sun box.
 
Old 11-06-2007, 11:27 PM   #5
complich8
Member
 
Registered: Oct 2007
Distribution: rhel, fedora, gentoo, ubuntu, freebsd
Posts: 104

Rep: Reputation: 15
Quote:
But tell me, does this Key pair work for Solaris also ? .i.e from local Linux box, i have to execute commands of remote Sun box.
Absolutely.

If you're trying to execute remote commands without going to a full shell, then you can specify the command you're trying to execute on the ssh command line -- eg:
Code:
ssh you@yourhost commandtoexecute
If you've got the same set of commands you're trying to execute on the remote system, you might consider turning them into a simple shell script. Similarly, if it's something that's going to happen at regular intervals, you may consider a cron job on the remote machine rather than having the local machine constantly poke it.

Last edited by complich8; 11-06-2007 at 11:32 PM.
 
Old 11-10-2007, 12:35 AM   #6
harishkrishnan
LQ Newbie
 
Registered: Apr 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks much....Looks like i can get some more ideas frm you people..

Here is what iam doing & expecting ur help on this...

See, i am doing an GUI appln in Linux using QT. We have a product which works on all the unix flavours(..Lin, Sun, Mac, HPux...)
The GUI application which am doing is bascically a testing tool which helps in testing this product.
So far what i have made is a standalone application i.e. it works only on a single Linux box. Now am working on extending this application for testing products on remote machines(Lin, Solaris, MAC) also.
So this is the actual requirement!

Few of the features of this appln are like viewing the log files, filtering the contents, viewing system properties, stop/start of product services...and some more.
-------------------------------------------------

So am assuming that, what all commands i have used to run on local machine, i can use the same commands for remote Linux machines also using - "ssh you@yourhost commandtoexecute" right? (with appropriate commands for Solaris, mac...)

I would definitely ask many questions as i progress on this..
Thanks very much in advance...
 
  


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
Can't SSH to remote machine: Connection closed by remote host Avatar Linux - Networking 34 05-24-2013 09:28 AM
Keep losing connection to remote machine through SSH/VNC cav Linux - Networking 3 04-23-2006 07:12 PM
ssh connection from a Windows machine to a Linux machine pistachio Linux - Networking 1 08-30-2005 10:45 AM
how to open a dilog on local machine when i do ssh to remote machine fahad26 Programming 3 05-03-2005 07:39 PM
ssh not connecting to a remote machine. Eux Debian 5 09-22-2004 04:44 AM


All times are GMT -5. The time now is 05:49 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration