Re: Question about ssh no login
- From: "Robert M. Riches Jr." <spamtrap42@xxxxxxxxxxx>
- Date: Sat, 28 Apr 2007 21:11:33 GMT
On 2007-04-28, sk8terg1rl <sk8terg1rl_2006@xxxxxxxxxxx> wrote:
Hi Robert, thanks for your help.
On Apr 28, 12:17 am, "Robert M. Riches Jr." <spamtra...@xxxxxxxxxxx>
wrote:
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 remotemach...@xxxxxxxxxxxxxxx <<EOF
ls
exit
EOF
It works, but I get the following message:
sk8terg1rl@home:~/.ssh> ./test
Pseudo-terminal will not be allocated because stdin is not a terminal.
[ls output follows]
sk8terg1rl@home:~/.ssh> cat test
ssh sk8terg1rl@xxxxxxxxxx << EOF
ls
exit
EOF
By the way, exactly what is "<< EOF" for? The above script still works
if I change either EOF to anything else (even non-matching) but stops
working if I remove the first EOF
./test: line 1: syntax error near unexpected token `newline'
./test: line 1: `ssh sk8terg1rl@xxxxxxxxxx << '
Someone else also pointed you to documentation on the usage
of hear-documents. While I haven't read that documentation,
it's probably worth studying.
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:
Yes, I noticed permissions aren't preserved upon scp. Thanks for
pointing that out.
Glad to help.
cat > local-script <<EOF
#!/bin/yourshell
ls
exit
EOF
chmod +x local-script
scp local-script remotemach...@xxxxxxxxxxxxxxx:/path/to/remote-script
ssh chmod +x remotemach...@xxxxxxxxxxxxxxx:/path/to/remote-script
ssh remotemach...@xxxxxxxxxxxxxxx:/path/to/remote-script
After a bit of testing, your chmod command should read:
ssh remotemachine@xxxxxxxxxxxxxxx chmod 777 /path/to/remote-script
Otherwise by doing this:
ssh chmod 777 remotemach...@xxxxxxxxxxxxxxx:/path/to/remote-script
You get the error:
ssh: chmod: Name or service not known
I would recommend 'chmod +x' rather than 'chmod 777' for
security reasons. If there is an unfriendly user on the
remote machine, with 'chmod 777' that user could change your
script before you run it and gain control of your account.
--
Robert Riches
spamtrap42@xxxxxxxxxxx
(Yes, that is one of my email addresses.)
.
- References:
- Re: Question about ssh no login
- From: Robert M. Riches Jr.
- Re: Question about ssh no login
- Prev by Date: Re: Does Firefox auto link to Google? Redux
- Next by Date: Re: Compiling the scriptbasic package
- Previous by thread: Re: Question about ssh no login
- Next by thread: Re: Question about ssh no login
- Index(es):
Relevant Pages
|