Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93334
  • 博文数量: 9
  • 博客积分: 330
  • 博客等级: 一等列兵
  • 技术积分: 117
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-05 18:36
文章分类

全部博文(9)

文章存档

2012年(4)

2011年(1)

2010年(4)

分类: 系统运维

2012-02-25 13:27:59

sshpass: 用于非交互的ssh 密码验证
 
ssh登陆不能在命令行中指定密码,也不能以shell中随处可见的,sshpass 的出现,解决了这一问题。它允许你用 -p 参数指定明文密码,然后直接登录远程服务器。 它支持密码从命令行,文件,环境变量中读取
 
$> sshpass -h
 
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

sshpass [-f|-d|-p|-e] [-hV] command parameters 中的 command parameters 和使用交互式密码验证的使用方法相同
 
#从命令行方式传递密码
 
    $> sshpass -p user_password ssh user_name@192.168..1.2
    $> sshpass -p user_password scp -P22 192.168.1.2:/home/test/t . 
 
#从文件读取密码
 
    $> echo "user_password" > user.passwd
    $> sshpass -f user.passwd ssh user_name@192.168..1.2
 
#从环境变量获取密码
 
    $> export SSHPASS="user_password"
    $> sshpass -e ssh user_name@192.168..1.2 

 
源码位置:
  
------------- end -------------
From: GS
-------------------------------

阅读(1502) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~