Script to login to another server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to login to another server
# 1  
Old 11-23-2009
Computer Script to login to another server

Folks;
I'm trying to write a shell script that should runs on one machine and to perform the following:

- The script should SSH to another machine using user name and password then runs a command on that machine then exit and bring the command output to the screen.

Thanks in advance for the help
# 2  
Old 11-23-2009
1. For logging in use, passwordless login or using expect give the password.

2. use -c to execute a command.

3. Normally it will show the output in the screen, and exits.

Code:
ssh username@hostname ls

This will execute ls in that host, shows the output, and exits.
# 3  
Old 11-24-2009
use rsh
# 4  
Old 11-24-2009
Thanks for replying folks;

- I must use SSH.
- I don't see from the answer where i can add the password for the SSH inside the script. the script should be able to login to the new machine using user and password.

- i'd like the user to pass in the IP address for the machine we need to SSH to it as it will change every time.

- Also, i need the user to get back the output from running the command inside the script

Thanks again for your help
# 5  
Old 11-24-2009
Create public SSH keys on all remote machines then add those keys to the authorized_keys2 file on the host you intend to run your script. This will allow for passwordless SSH connection.

You could assign a variable the output by running your SSH command in backticks.

ssh_output=`ssh user@host command`
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running a script on remote server kills my login session

Hi there, I'm trying to run a script remotely on a server in a particular directory named after hostname which already exists, my login session gets killed as soon as I run the below command. Not sure what is wrong, is there a better way to do it ? Note: I can also use nohup command to run... (14 Replies)
Discussion started by: mbak
14 Replies

2. 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

3. 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

4. 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

5. Shell Programming and Scripting

SFTP script to automate login in to remote server

Greetings, guys. I'm not much of a programmer forgive me for being a noob, because of someone leaving, I was put in an IT spot where I have to figure out a few things. Being new to Linux and programming has been a challenge. My boss has asked me to create an automated script to connect to a 3rd... (7 Replies)
Discussion started by: giovannym
7 Replies

6. 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

7. Shell Programming and Scripting

Shell script in tracking both the passed and failed login in a unix server

Can you help me in providing the following output or a quite similar to this from a shell script ? *** Logins Summary Information ***** ---------------------------------- Failed Login Attempts for Invalid Accounts Date Time IP-ADD Account ... (0 Replies)
Discussion started by: linuxgeek
0 Replies

8. 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

9. 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

10. 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