Linux间无密码ssh
时间:2014-12-24 13:57 来源:灵犀志趣 作者:灵犀志趣
来自《灵犀志趣》的脚本来完成无密码验证,省事省力。
执行方式 sh nopasswd USER REMOTE_HOST
执行此脚本前,请确认:
-
本机上已有 id_dsa.pub ,若无。 使用命令 ssh-keygen -t dsa 获得。
-
远程机上登录用户家目录下,已经有 .ssh 文件夹,若无创建之。
nopasswd: 将本地已经生成的id_dsa.pub拷贝到需要访问的机器home下,然后将id_dsa.pub的内容增加到~/.ssh/authorized_keys中,最后确保权限设置正确。
#!/bin/sh
scp ~/.ssh/id_dsa.pub $1@$2:~/
ssh $1@$2 " touch ~/.ssh/authorized_keys ; cat ~/id_dsa.pub >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys; exit"
(责任编辑:IT)
来自《灵犀志趣》的脚本来完成无密码验证,省事省力。 执行方式 sh nopasswd USER REMOTE_HOST 执行此脚本前,请确认:
nopasswd: 将本地已经生成的id_dsa.pub拷贝到需要访问的机器home下,然后将id_dsa.pub的内容增加到~/.ssh/authorized_keys中,最后确保权限设置正确。 #!/bin/sh scp ~/.ssh/id_dsa.pub $1@$2:~/ ssh $1@$2 " touch ~/.ssh/authorized_keys ; cat ~/id_dsa.pub >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys; exit" (责任编辑:IT) |