Re: Question about ssh no login
- From: "Robert M. Riches Jr." <spamtrap42@xxxxxxxxxxx>
- Date: Sat, 28 Apr 2007 00:17:16 GMT
On 2007-04-28, sk8terg1rl <sk8terg1rl_2006@xxxxxxxxxxx> wrote:
Hi group,
I've implemented ssh no logins between 2 computers. Basically it
involved generating a public & private key pair with no passphrase and
appending the public keys to "authorized_hosts2" in the ".ssh" folder
for either machine.
How do I run commands in the remote machine from the local machine's
bash?
I tried a simple script on the local machine containing "ssh
remotemachine@xxxxxxxxxxxxxxx; ls; exit". It logs in fine but ignores
the rest of the script.
Any input please?
The script as you wrote it does the following on the local
machine:
ssh remotemachine@xxxxxxxxxxxxxxx
ls
exit
I suspect you don't see the 'ls' and 'exit' executed
locally, because the ssh process is waiting to read commands
on its stdin, because the ssh command you gave sets it up to
open an interactive session, using its stdin and stdout if I
understand correctly.
Do you want the 'ls' and 'exit' to be executed on the remote
machine? If so, you need to send those commands to the ssh
processes with something similar to the following: (I
haven't tested this, so YMMV.)
ssh remotemachine@xxxxxxxxxxxxxxx <<EOF
ls
exit
EOF
If I'm right, this will cause the ssh process to read "ls"
followed by "exit" on its stdin and execute them on the
remote machine.
Another option you might consider if you can't get the above
to work would be to write your script into a file, with
proper first line if desired/needed, scp the file to the
remote machine, and then execute the remote copy of the file
as a script, doing something like the following on the local
machine:
cat > local-script <<EOF
#!/bin/yourshell
ls
exit
EOF
chmod +x local-script
scp local-script remotemachine@xxxxxxxxxxxxxxx:/path/to/remote-script
ssh chmod +x remotemachine@xxxxxxxxxxxxxxx:/path/to/remote-script
ssh remotemachine@xxxxxxxxxxxxxxx:/path/to/remote-script
One of the chmod commands might not be needed.
HTH
--
Robert Riches
spamtrap42@xxxxxxxxxxx
(Yes, that is one of my email addresses.)
.
- Prev by Date: Re: Accidental deletion. Help please!
- Next by Date: Re: Question about ssh no login
- Previous by thread: Accidental deletion. Help please!
- Next by thread: Re: Question about ssh no login
- Index(es):
Relevant Pages
|