Visit Our UNIX and Linux User Community


Remote Connection (SSH)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remote Connection (SSH)
# 1  
Old 06-17-2005
Lightbulb Remote Connection (SSH)

Hello all,

I connect usually to one enviornment "dev" daily and then ftp some files to some other enviorment "uat" and then login to "uat" and run some scripts to process these files.

I was thinking to automate the process, where running one script from "dev" will complete all task required to be done on "uat".

sftp part I have already automated. but a bit confused with ssh part.
I am able to login to uat from dev via ssh, but problem is

how to issue a series of command through a script once connected to remote uat?

I checked man pages and forum, but could not locate anything useful.
Any help will be highly appreciated.

Regards,
Rishi
# 2  
Old 06-17-2005
Instead of initiating the process from "dev" i suggest running some script from "uat", that would make things easier. You can use "scp" (man scp) to collect the files from dev and don't have to think about ways to start processes remotely.

If you really need to do it the way you described it for some outside reason you could pack all the commands you want to run remotely into a script there and call this script via ssh (man ssh) using a command like "ssh -l username uat scriptname_to_execute.sh". This will login to machine uat as user "username" and execute the command "scriptname_to_execute.sh", then terminate the connection.

Hope this helps.
bakunin
# 3  
Old 06-17-2005
CPU & Memory

The reason why I wish to execute process from dev is... its not only uat the file need to be transferred there are many more...sys, rpt, prod etc...

if I go other way round , I end up running scripts from all env.

The idea mentioned of assembling all required commands in one script and fire it remotely is perfectly ok, but I my commands will be dynamic and based on
conditions like files found on dev.

One way to achieve same, I could create a dynamic script first ftp it, and then call via ssh. But I don't want to disturb file enviornment on remote creating temp files.

So we you can suggest any way where we pass bunch of commands to ssh, to be processed on remote will be good.

Thanks for your help.
Rishi
# 4  
Old 06-17-2005
Quote:
Originally Posted by RishiPahuja
Hello all,

I connect usually to one enviornment "dev" daily and then ftp some files to some other enviorment "uat" and then login to "uat" and run some scripts to process these files.

I was thinking to automate the process, where running one script from "dev" will complete all task required to be done on "uat".

sftp part I have already automated. but a bit confused with ssh part.
I am able to login to uat from dev via ssh, but problem is

how to issue a series of command through a script once connected to remote uat?

I checked man pages and forum, but could not locate anything useful.
Any help will be highly appreciated.

Regards,
Rishi
If I did not get it wrong, why can't you put the script in uat and run it remotely from dev? such as
[dev] $ ssh <id>@uat <the script file located in UAT>

Tom
# 5  
Old 06-21-2005
Error

Thanks Tom for your suggestion.
I know it is the only alternative I have as of now.

For this I need to create a dynamic script as per requirement and along with data files I need to sftp them, and finally through ssh invoke it.

Any alternatives where I can invoke a series of command from my local machine one by one, will be preferrable for reasons like local log creation etc.

Any help is welcome.

Regards,
Rishi
# 6  
Old 06-21-2005
Quote:
Originally Posted by RishiPahuja
Any alternatives where I can invoke a series of command from my local machine one by one, will be preferrable for reasons like local log creation etc.
You could print some debug statements in the script and redirect the output of the script to some local file. This should work.
i.e. as Tom said:
[dev] $ ssh <id>@uat <the script file located in UAT> >> /whatever/log/file/you/want

The logfile will get created on the local system.
# 7  
Old 06-22-2005
Question

remote logging and executing worked out with all you people effort.

but got one more complication.

The script I am running on remote is interactive one and takes user response "Y/N" type.

In the remote script I read from terminal.

read response < /dev/tty

when I run this piece it throws error saying that"cannot open /dev/tty"
any help to figure out a solution is a welcome.

Thanks in advance.

Regards,
Rishi

Previous Thread | Next Thread
Test Your Knowledge in Computers #696
Difficulty: Medium
The Cathedral model, in which source code is available with each software release, but code developed between releases, is restricted to an exclusive group of software developers.
True or False?

10 More Discussions You Might Find Interesting

1. BSD

Connection SSH to remote by ssh

Hello guys! I am setting up a script to access a unix remote server. My problem is that when I put the ssh line "my host", the script does not wait for the server response asking for the password to execute the line in which I put the password, that is, I need to put a form in which script has a... (1 Reply)
Discussion started by: aroucasp
1 Replies

2. Shell Programming and Scripting

Ssh to validate multiple remote hosts connection validation.

Dear Folks, I am trying to read a config file contains ip and port numbers. i want to read each line of the config file and check ssh connection is happening or not. Kindly guide. Config file: abc@1.2.342 22 abc@1.2.343 22 abc@1.2.344 22 abc@1.2.345 22... (9 Replies)
Discussion started by: sadique.manzar
9 Replies

3. Ubuntu

ssh connection unstable on remote server

Hi I hope someone can spot what is wrong with this ssh connection as it has me baffled. I am trying to set up a remote ssh connection (passwordless) to a remote 'server', (Ubuntu laptop at home). I have tried these steps with rsa and dsa key types, (currently dsa) - 1) ssh-keygen... (4 Replies)
Discussion started by: steadyonabix
4 Replies

4. Shell Programming and Scripting

How to automate SSH remote connection with a shell script

Hi Guys! I am trying to write a shell script for automated ssh. vairable user and passwd have initialized correctly, but when I use the following it still prompting me for the password. #!/usr/bin/bash user='root@10.14.76.225' passwd='admin' ssh $user $passwd uptime exit I... (3 Replies)
Discussion started by: pinpe
3 Replies

5. AIX

ssh failed to login in remote connection

i am in node acbs01b and i use the root@fcbs01b to login and i have the below message . ssh root@fcbs01b @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT... (6 Replies)
Discussion started by: thecobra151
6 Replies

6. Red Hat

Unable to SSH into machine - ssh_exchange_identification: Connection closed by remote host

For a few days now I have been experiencing issues when trying to SSH into 1 of my machine. I get the following output when running 'ssh -vvv': server1:/home/mymadq> ssh -l root -vvv server2 OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 debug1: Reading configuration data /etc/ssh/ssh_config... (3 Replies)
Discussion started by: jaapar
3 Replies

7. Shell Programming and Scripting

ssh connection from remote machine in solaris

Hi! I have two solaris 10 machines(say 10.1.1.1,10.1.1.2). i have installed rsync on 10.1.1.2, 10.1.1.1::: Sun Microsystems Inc. SunOS 5.10 Generic January 2005 -bash-3.00$ ssh 10.1.1.2 "echo $PATH" Password:... (4 Replies)
Discussion started by: dddkiran
4 Replies

8. Shell Programming and Scripting

check ssh connection to remote host

I am using KSH and I need to check whether the remote host has been configured with ssh public key. Is there any way we can check inside a script? (6 Replies)
Discussion started by: praveenbvarrier
6 Replies

9. Shell Programming and Scripting

Remote SSH Connection Using Script

Hi, I am new to Shell Scripting. Can anybody help me in writing a Script Which Could Login from a Unix box to a Remote Unix box which accepts the user credentials automatically and display the result for checking the Disk Space Utilisation (Without running any SSH agent). (1 Reply)
Discussion started by: ajith_tg
1 Replies

10. UNIX for Advanced & Expert Users

Solaris 9 remote login (ssh) drops connection

Hello All, I wonder if you can help me... Let me give you some set-up details before I ask you the question. I have Ultra-60 at home with Solaris 9 and recommended patch cluster installed. The machine is connected to a Linksys WAG54G ADSL router/modem through RJ45 ethernet cable. The... (2 Replies)
Discussion started by: ahmerin
2 Replies

Featured Tech Videos