1

I am trying to log into a linux node using a shell script for which I have the username and password. So i want to run a few commands on that server and then I need to capture that output and I need to show it on a HTML page.

Now firstly I am facing issues with login into the server using a shell script (I even tried .BAT file), so need help regarding it.

My incomplete script is as below:

@echo off 
cls
ssh [email protected]@nodename01.xxx.xxx.xxx01.xxx.com
pause

I need to enter the password when it asks in next step and also need to hit enter after it. Also after login need to pass 'Yes' when I log in for the first time.

Any help is appreciated in advance.

4
  • Both "shell" and "script" apply to many shells. Which do you actually target? You write about .BAT (meaning Windows cmd.exe?) but you tagged your question with "bash". In any case, "I am facing issues" is not really a good description of those issues. Please read How to Ask, in case you haven't already. Commented May 6, 2021 at 16:45
  • As far as I remember, ssh does not accept a password from stdin, and it does not have an parameter/option to pass one to it, therefore you'll need something like sshpass Commented May 6, 2021 at 16:52
  • stackoverflow.com/questions/28197540/… Commented May 6, 2021 at 17:44
  • stackoverflow.com/questions/14989326/… Commented May 6, 2021 at 17:45

1 Answer 1

1

before run the script, you should gen ssh-key

ssh-keygen

Then run this command

ssh-copy-id 192.168.10.10
ssh-copy-id {host IP}

then run your script

Sign up to request clarification or add additional context in comments.

1 Comment

This addresses only one of their three problems.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.