login to multiple server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting login to multiple server
# 1  
Old 06-05-2009
login to multiple server

i want to login (telnet) to 2 different servers. Then I will execute command in those servers as many time as I need(i will choose the server to execute the command). Is it possible?

i.e, my script will be stayed log on two servers (server1, server2). Then I will execute command by choosing one server at a time. It will take input from the terminal and decide from which the command has to be executed. I wanna to avoid login every time I need to execute command.

it may be bash, perl or others. i can log on using expect script. please help me
# 2  
Old 06-05-2009
I would suggest using passwordless SSH instead of telnet(1), you can then run:
Code:
# ssh user@server.domain.com command

Do you can do something like:
Code:
COMMAND="ls -l"
SERVERNAME=server.domain.com
ssh user@${SERVERNAME} "${COMMAND}"

And use a case statement to select the server depending on what command you have selected if the command is to be a parameter to your script then that line needs to be:
Code:
COMMAND="$@"
if [ -z "${COMMAND}" ]; then
  echo "ERROR: No command given as parameter, aborting!"
  exit 99
fi

.

Either that or look into using /etc/hosts.equiv on the server but telnet and hosts.equiv are insecure.

Does this help?

Last edited by TonyFullerMalv; 06-05-2009 at 07:47 PM..
# 3  
Old 06-05-2009
Thanks TonyFullerMalv for ur quick reply!

passwordless SSH is not possible for me as I'm not root user of the server. Is it possible by using subshell?
# 4  
Old 06-06-2009
you can be any user to use passwordless ssh .So you can proceed with TonyFullerMalv's suggestion.
# 5  
Old 06-06-2009
Thanks TonyFullerMalv
I can use either ssh or telnet. It is not the problem. I do not want to log on every time I execute the command. Main thing is that I will be stayed log on to two servers from a single script and It will execute my desired command to desired server taking input of the shell.
Is it possible by using subshell? i'm not clear about subshell.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Not able to login AIX server but able to login thru console.

Hi, i am able to login to AX server thru console but not able to login directly thru server. also the server is not ping-able with other server. filesystem is fine. and OS version is AIX 5.3. please let me know if you need any specific log. thx in advance. Scriptor (2 Replies)
Discussion started by: scriptor
2 Replies

2. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

3. Windows & DOS: Issues & Discussions

Passwordless login from Linux server to windows server

Hi, I am a newbie and has been given a task to connect to a windows server from a linux server (using putty of course; for file transfer) that too passwordless. Searching through google I found "ssh-keygen" but this also couldn't work because as I tried ssh <username>@<windowsServerIP>, it says... (5 Replies)
Discussion started by: pratria
5 Replies

4. Shell Programming and Scripting

Shell Script for viewing multiple logs from multiple server

I am new to Shell scripting and below is my requirement. I need to search some specific word e.g. "exception" or "transaction" from log file. We have multiple env e.g. Level1 , Level2 etc and each env have Multiple boxes e.g. For Level 1 env we have "test11.test.com" , "test12.test.com". Each... (1 Reply)
Discussion started by: peeyush
1 Replies

5. AIX

User Account Login Login on your AIX server

I want to learn AIX. I would like to find someone who would be willing to give me a login to their AIX home lab server. My intent is to poke around and discover the similarities and differences of AIX compared to other *NIXs. I am a UNIX admin so I can think of what some immediate concerns may... (1 Reply)
Discussion started by: perl_in_my_shel
1 Replies

6. Cybersecurity

APACHE: Tie in Web Page login with server login

Hello, I have created a web page on a server using apache and added .htaccess and .htpasswd in the folder for authentification. I was wondering if there was anyway to tie-in the login for this page with the login used to logon to the server. i.e. the same login info. is used for both, when... (1 Reply)
Discussion started by: WhotheWhat
1 Replies

7. Web Development

APACHE: Tie in Web Page login with server login

Hello, I have created a web page on a server using apache and added .htaccess and .htpasswd in the folder for authentification. I was wondering if there was anyway to tie-in the login for this page with the login used to logon to the server. i.e. the same login info. is used for both,... (2 Replies)
Discussion started by: WhotheWhat
2 Replies

8. Shell Programming and Scripting

passwordless login from a server to another server

Hi guys I am logged into one solaris server and I want to ssh other solaris servers and perform some commands. If I use script it asks for password. How to login without supplying password and execute some commands using script? I don want to use expect utility. Please help (2 Replies)
Discussion started by: johnl
2 Replies
Login or Register to Ask a Question