Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH expect #30

Open
LianelLars opened this issue Aug 8, 2023 · 2 comments
Open

SSH expect #30

LianelLars opened this issue Aug 8, 2023 · 2 comments

Comments

@LianelLars
Copy link

If i do:

#main_file.nim
import shell

shell:
  "ssh [email protected] whoami"
  expect: "password:"
  send:"my_password"

nothing happend. But if i do:

#first_file.nim
import shell

shell:
  ./second_file
  expect: "something"
  send:"i send info"
  
#second_file:
echo "Enter something"
let a: string = readLine(stdin)
echo "Entered: ", a

Everything works correctly.
Soooo.... is it have to working like that? :)

@Vindaar
Copy link
Owner

Vindaar commented Aug 9, 2023

The issue is that password input is handled differently in the terminal (not via stdin). I'm not sure if it's possible to catch that from a process and feed the password. Sounds kind of like a security nightmare. Maybe there is a way, but one would have to do some research.

For something like this you should really just use an SSH key and then use ssh-agent.

eval `ssh-agent`
ssh-add ~/.ssh/id_<my_ssh_key>

to avoid the password requirement. I haven't done this myself, so I'm not entirely sure about how to make sure the SSH agent is available in the subprocess that is started (I've only used ssh-agent in a contained terminal session).

@RokkuCode
Copy link

RokkuCode commented Oct 13, 2023

alternatively: use the key directly with the ssh command:

ssh -i ~/.ssh/id_<my_ssh_key> [email protected] whoami

in my opinion using passwords with ssh should removed and key only auth should the only way to auth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants