用sshpass实现ssh的自动登陆
来源:互联网 发布:交互设计类软件 编辑:程序博客网 时间:2024/05/16 17:23
要实现ssh自动登录,网上搜了一下,主要有两种方法:1、生成公钥。2、编写expect脚本。这两种方法,还有一种是sshpass:
用法:
sshpass 参数SSH命令(ssh,sftp,scp等)。
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
比如说:
scpabc@192.168.0.5:/home/xxx/test/root 这个命令的作用是将服务器端文件test传到本地文件夹/root下。
利用sshpass,假设密码为efghi,则可写作:
ssh -p efghiscp abc@192.168.0.5:/home/xxx/test /root
另外,对于ssh的第一次登陆,会提示:“Are you sure you want to continue connecting(yes/no)”,这时用sshpass会不好使,可以在ssh命令后面加上 -oStrictHostKeyChecking=no来解决。比如说上面的命令,就可以写作ssh -p efghi scpabc@192.168.0.5:/home/xxx/test /root -oStrictHostKeyChecking=no。
用法:
sshpass 参数SSH命令(ssh,sftp,scp等)。
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
另外,对于ssh的第一次登陆,会提示:“Are you sure you want to continue connecting(yes/no)”,这时用sshpass会不好使,可以在ssh命令后面加上 -oStrictHostKeyChecking=no来解决。比如说上面的命令,就可以写作ssh -p efghi scpabc@192.168.0.5:/home/xxx/test /root -oStrictHostKeyChecking=no。
0 0
- 用sshpass实现ssh的自动登陆
- 用sshpass实现ssh的自动登陆
- sshpass实现ssh自动输入密码登陆服务器
- shell实现SSH自动登陆
- 远程自动备份 rsync+ssh+sshpass
- 实现ssh自动登陆的三种方式
- shell脚本实现无密码交互的SSH自动登陆
- shell脚本实现无密码交互的SSH自动登陆
- shell脚本实现无密码交互的SSH自动登陆
- shell脚本实现无密码交互的SSH自动登陆
- shell脚本实现无密码交互的SSH自动登陆
- shell脚本实现无密码交互的SSH自动登陆
- ssh 自动登陆的权限
- 使用 alias 以及 sshpass 命令简化ssh登陆步骤
- SSH实现无密码自动登陆
- linux脚本实现ssh自动登陆远程桌面
- ssh+filter+cookie实现自动登陆
- 使用sshpass进行ssh/scp/sftp/自动输入密码
- 连接mongodb时候报:Invalid credentials for database 'xxx'.
- iOS实现多个异步线程同步的操作
- Bitmap那些事(3)
- Android 桌面悬浮窗进阶,QQ手机管家小火箭效果实现
- NetHogs - Monitor Per Process Network Bandwidth Usage in Real Time
- 用sshpass实现ssh的自动登陆
- php中magic_quotes_gpc函数一些用法
- Android Error: android.os.NetworkOnMainThreadException
- HBuilder Android平台离线打包支付插件配置
- 用qt编译Android应用(windows和Linux)
- Email 发邮件完整代码(Java实现)
- Linux源代码目录分析
- 模拟微信短视频拍摄
- Android签名简介