Bash:控制 SSH [英] Bash: controlling SSH

查看:21
本文介绍了Bash:控制 SSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 bash 文件,它要求提供 IP、密码等,以便 OpenSSH 连接到设备.

I have this bash file, which asks for IP, password, etc. for OpenSSH to a device.

现在,如果我使用ssh root@ip,我必须输入密码.这真的很烦人.其次;我不能让我的脚本向它发送命令.

Now, if i use ssh root@ip, i have to enter the password. This is really irritating. Secondly; i cannot let my script send commands to it.

这就是我想要的->

  1. 不是密码问题;我已经找到了一些东西;但它告诉我找不到命令?:

  1. Not the password thing; i already found something; but it tells me the commands are not found?:

#!/usr/bin/expect -f

生成 ssh root@$IPADDR

期望密码:"

睡眠1

发送$rpass "

  1. 我希望用户能够看到一些可供选择的菜单;在那之后;每一条命令都是为他完成的.比如一个新窗口,或者类似的东西?

  1. I want the user to be able to see some menus where it can choose from; after that; every command is done for him. So like a new window, or something like that?

我不想使用:- 任何外部的东西- 无需额外编辑 SSH 连接

I do not want to use: -Any external stuff -No extra editing of the SSH connection

BASH 信息:GNU Bash,v. 4.0.33(1)-release (i486-pc-linux-gnu),在 Linux Mint 上运行.但它必须可用于多个 linux 发行版,也可用于 Mac?

BASH INFO: GNU Bash, v. 4.0.33(1)-release (i486-pc-linux-gnu), running on Linux Mint. But it got to be available for several linux distro's, and also on Mac?

推荐答案

许多工具可以不遗余力地防止您正在做的事情.我建议使用 ssh 公钥来解决这个问题,而不是密码.

Many tools to go great lengths to prevent what you are doing. I recommend using ssh public keys to solve this problem instead of passwords.

最好的选择是基于开源编写自己的修改过的 ssh 客户端,以便控制密码管理.

The big alternative is to write your own modified ssh client based on the open source so as to take control of the password management.

哦,好吧,我忘了.您可能可以使用 pty 来超越它,因为/dev/tty 将是您控制的对象.期望可能会帮助您解决这个问题.

Oh, well, I forgot. You can probably outsmart this with a pty, since then /dev/tty will be what you control. expect might help you with this.

这篇关于Bash:控制 SSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆