1 connection ssh automation tcl sh
如果有人可以告诉我如何使用用户名和密码作为参数连接到unix服务器将是有帮助的.我的用户名和密码是"anitha".
如何使用此用户名和密码创建一个自动连接到我的unix服务器的shell脚本?
小智 5
我想你想从网络远程连接到你的*nix服务器.根据我的猜测,来:
连接到远程*nix服务器,每个人都使用SSH
ssh anitha@anitha ip-to-unix-server
自动连接,写简单的bash shell环绕你的ssh connect命令并做一些事情,不建议,你应该使用ssh密码少登录(又名公钥/私钥)
#!/usr/bin/env bash
ip=172.16.0.1 #replace 172.16.0.1 with your unix server's ip
username=anitha #your ssh username
password=anitha #your ssh password
command=who #what do you want to do with remote server
arguments= #arguments for your command
expect -c 'spawn ssh $username@$ip ; expect password ; send "$password\n" ; interact'Run Code Online (Sandbox Code Playgroud)无需输入密码即可连接,您可能需要使用SSH密码少登录
| 归档时间: |
|
| 查看次数: |
20382 次 |
| 最近记录: |