* How can I login with ssh in bash shell ?
@ 2003-06-24 17:05 wolfgang127jp
2003-06-24 19:59 ` Robin Doer
0 siblings, 1 reply; 3+ messages in thread
From: wolfgang127jp @ 2003-06-24 17:05 UTC (permalink / raw)
To: linux-newbie
Hi gurus,
I wanna login to my server with ssh command in bash shell.
I found a script that login to a server with ftp command in bash shell.
The following is the snippet of a ftp shell..
---------------------------
ftp -n $Server <<End-Of-Session
user anonymous "$Password"
binary
bell # Ring 'bell' after each file transfer
cd $Directory
put "$Filename.lsm"
put "$Filename.tar.gz"
bye
End-Of-Session
----------------------------------
so I made a simple script(simple.sh) below.
(abcdefg is the password of my_user)
----------------------------------
#!/bin/sh
ssh my_user@my_server <<END
abcdefg
echo "It works !!" > does_this_script_work.txt
exit
END
exit 0
---------------------------------
The result was....
-----------------------------
$ ./simple.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
my_user@my_server's password:
-----------------------------
Asking me the password ...
Why doesn't it work ?
I know It's not secure cuz the password is in the script, but I really
wanna make it work.
Please give me any hints.
Thanks in advance.
wolfgang.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How can I login with ssh in bash shell ?
2003-06-24 17:05 How can I login with ssh in bash shell ? wolfgang127jp
@ 2003-06-24 19:59 ` Robin Doer
2003-06-26 17:02 ` Stephen Samuel
0 siblings, 1 reply; 3+ messages in thread
From: Robin Doer @ 2003-06-24 19:59 UTC (permalink / raw)
To: wolfgang127jp, linux-newbie
Am Dienstag, 24. Juni 2003 17:05 schrieb wolfgang127jp@ybb.ne.jp:
> Hi gurus,
>
> I wanna login to my server with ssh command in bash shell.
> I found a script that login to a server with ftp command in bash shell.
>
> [...]
> ----------------------------------
>
> so I made a simple script(simple.sh) below.
> (abcdefg is the password of my_user)
> ----------------------------------
> #!/bin/sh
>
> ssh my_user@my_server <<END
> abcdefg
> echo "It works !!" > does_this_script_work.txt
> exit
> END
>
> exit 0
> ---------------------------------
>
> The result was....
> -----------------------------
> $ ./simple.sh
> Pseudo-terminal will not be allocated because stdin is not a terminal.
> my_user@my_server's password:
> -----------------------------
> Asking me the password ...
>
> Why doesn't it work ?
That will not work because, however, ssh doesn't read the passwort from stdin
(like ftp).
But there's a way to use ssh without a password-request:
On your local machine create a key with "ssh-keygen -t rsa" (use empty
passphrase). After that copy the public part of the key (located in
~/.ssh/id_rsa.pub) to your remote machine under ~/.ssh/authorized_keys).
Now your script should work.
Hope it helps,
Robin
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How can I login with ssh in bash shell ?
2003-06-24 19:59 ` Robin Doer
@ 2003-06-26 17:02 ` Stephen Samuel
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Samuel @ 2003-06-26 17:02 UTC (permalink / raw)
To: Robin Doer; +Cc: wolfgang127jp, linux-newbie
the public key should go into authorized_keys2
alsoe: I'd suggest using:
ssh-keygen -f nopw.key -t rsa
you will end up with the private key in nopw.key
and the public key in nopw.key.pub
You can then do: ssh -i nopw.key remote_host
The main difference here is that you don't end up with your
passwordless key being your default (probably a bad idea).
BTW: you can setup ssh so that the recipient machine, when
it accepts the passwordless key can only execute one specific
command. (makes it harder for a hacker to cause you damage
if they get hold of the key).
Robin Doer wrote:
>>----------------------------------
>>
>>so I made a simple script(simple.sh) below.
>>(abcdefg is the password of my_user)
>>----------------------------------
>>#!/bin/sh
>>
>>ssh my_user@my_server <<END
>>abcdefg
>>echo "It works !!" > does_this_script_work.txt
>>exit
>>END
>>
>>exit 0
>>---------------------------------
>>
>>The result was....
>>-----------------------------
>>$ ./simple.sh
>>Pseudo-terminal will not be allocated because stdin is not a terminal.
>>my_user@my_server's password:
>>-----------------------------
>>Asking me the password ...
>>
>>Why doesn't it work ?
>
>
> That will not work because, however, ssh doesn't read the passwort from stdin
> (like ftp).
>
> But there's a way to use ssh without a password-request:
>
> On your local machine create a key with "ssh-keygen -t rsa" (use empty
> passphrase). After that copy the public part of the key (located in
> ~/.ssh/id_rsa.pub) to your remote machine under ~/.ssh/authorized_keys).
> Now your script should work.
--
Stephen Samuel +1(604)876-0426 samuel@bcgreen.com
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bring it to life.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-06-26 17:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-24 17:05 How can I login with ssh in bash shell ? wolfgang127jp
2003-06-24 19:59 ` Robin Doer
2003-06-26 17:02 ` Stephen Samuel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox