Visit Our UNIX and Linux User Community


Sending commands to a remote server


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sending commands to a remote server
# 1  
Old 10-28-2010
Sending commands to a remote server

Hi I have managed to connect to a remote server via ssh, but nothing will actually send through to the remote server screen through my script...it waits until i am back to the main terminal before it outputs anything.

Can anyone tell me how to get commands to send through to the remote server?

Thanks
Hopper
# 2  
Old 10-28-2010
when you try and interactive connection to the remote machine using ssh, are you prompt for entering login+password or not ?
If not, (and if you still can get connected to the remote machine) then it means that the authentication keys exchange is correctly setup so you should be able to run it using your script.
Otherwise you should add your public authentication key to the authorized_keys file of the remote machine and check that ssh is configured properly.
# 3  
Old 10-28-2010
Yes, with ssh I usually start trying to get this running on both ends:
Code:
ssh2 localhost pwd

If I want passwordless login and complete trust, I copy the entire $HOME/.ssh*/ to the remote $HOME.

If $HOME is a mount onto multiple systems, that dir $HOME/.ssh/ or $HOME/ssh2/ is moved; see "man ssh" and "man sshd_config 5" (add 2 after ssh if you have made it up to the better ssh2), but usually see /etc/ssh2/ssh2_config under UserConfigDirectory.

That makes the keys match, although it also breaks localhost/127.0.0.1 entries until you remove the old system localhost/127.0.0.1 line in authorized_users or whatever -- it tells you.
# 4  
Old 10-29-2010
It always helps to know what command you typed.

Maybe try the "-n" parameter to "ssh". This often cures this type of problem.
# 5  
Old 10-29-2010
The -n is a speed up and simplification, as when there is no input stdin only output, ssh does not need to fork off a child or thread to watch stdin. Some commands get very confusing without it, like:
Code:
ssh2 somehost ls -lt /xyz | pg

Both 'ssh2' and 'pg' will be reading /dev/tty, so 'pg' will seem unresponsive half the time, because 'ssh2' does not know 'ls' does not read stdin.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #293
Difficulty: Easy
Linux is the most popular operating system among supercomputers today (2019).
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute commands on remote server using expect script?

I need to copy python script file to around 100 servers using expect script. 1. Copy script to my user home first(/home/myhome) on each remote server 2. change permissions on copied file to 766. 3. sudo to appuser1 account on remote server. copy script file from my user home to /usr/bin/... (1 Reply)
Discussion started by: kchinnam
1 Replies

2. Shell Programming and Scripting

Ssh - running commands on remote server

Hi, I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this. At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I... (1 Reply)
Discussion started by: newbie_01
1 Replies

3. Shell Programming and Scripting

How to run commands on remote server using ssh password less authentication?

Hi, I need to run a script located in a directory on remote server by using ssh authentication from my local unix server. Can anyone help me in this. I have tried the below command. It worked for echo command but when i tried to open a file using cat command it is showing "cat: cannot open... (6 Replies)
Discussion started by: ssk250
6 Replies

4. Shell Programming and Scripting

Running Commands on a Remote Linux Server over SSH

Hello, I'm trying to create a ksh script to ssh to a remote server, enter the password and a couple commands. For security reasons I have changed the login, password and ip in my example. #!/bin/ksh ssh -t -t username@12.5.5.3 << EOF password cd bin pwd EOF When I run it. It... (5 Replies)
Discussion started by: seekryts15
5 Replies

5. Programming

Sending and Receiving data between Client, HTTP Proxy, and Remote Server

I am having problems receiving data from a remote server. It seems that I can send an HTTP request to any host such as http://www.google.com, but I can't get a reply. I'm sending the host a HTTP 1.0 request that is formatted as such: GET / HTTP/1.0 Host: http://www.google.com Connection:... (0 Replies)
Discussion started by: shubham92
0 Replies

6. Shell Programming and Scripting

executing commands in remote server using ssh

I have some commands which need to be executed in remote machine. I have Linux Server from where I need to connect to Solaris server using ssh and then declare some variable over there and run some commands. I don't want to call a script which is present in Solaris server from Linux server... (7 Replies)
Discussion started by: maitree
7 Replies

7. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

8. UNIX for Advanced & Expert Users

Commands to copy a tar.gz file from a Remote Unix Server to Local Desktop.

Hi, Just wanted to know, how can I ftp/transfer/copy a (design.tar.gz) archive from a Unix Server (sdmc222.sdmc.cp-srv.com) which is at a remote location, to my Windows Desktop. Obviously, it is not possible at cmd prompt on my Windows using the following commands :- ftp... (3 Replies)
Discussion started by: marconi
3 Replies

9. UNIX for Dummies Questions & Answers

Sending Commands to a Remote Host

I am trying to write a script that logs into an SMTP server and authenticates as a user or verifies that a user exists. I can do all this from the command line but I don't know how to write a script to do this for me, I login and then the script stops, I'm sure this is some basic principle. ... (3 Replies)
Discussion started by: safetytrick
3 Replies

Featured Tech Videos