使用密码自动进行 SSH 登录的 Shell 脚本 [英] Shell script to automate SSH login using password

查看:49
本文介绍了使用密码自动进行 SSH 登录的 Shell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用密码自动登录 SSH.我不能使用 expect 命令或 sshpass 等.所以我只能选择直接使用密码.在谷歌做了很多研究,没有得到任何解决方案...... :(

I am trying to automate SSH login by using password. I can't use expect command or sshpass etc. So I am left with only option to use password directly. Did lot of research in google and didn't get any solution... :(

请帮我解决这个问题.

我试过的代码是.

#!/bin/bash
USERNAME=user1
PASSWORD=abcd1234
HOSTS="server01.mat.us"
ssh ${HOSTS} -l ${USERNAME} -p ${PASSWORD}

推荐答案

如果可能,我建议使用 ssh 密钥而不是密码.

I'd recommend to use ssh keys instead of password if it's possible.

此脚本可以帮助您将公钥上传到所需的远程机器:

This script can help you to upload your public key to desired remote machine:

https://github.com/aprey10/ssh-authorizer

这篇关于使用密码自动进行 SSH 登录的 Shell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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