.在client端设置# git config --g......_无密码远程设置服务器">
赞
踩
- #!/usr/bin/expect
- spawn ssh Username@ServerIP
- expect "*password:"
- send "Password\r"
- expect "*#"
- interact
- <1>.在client端设置
- # git config --global user.name "zhaog"
- # git config --global user.email "zhaog@mail.com"
- <2>.生成秘钥
- # ssh-keygen
- # ls ~/.ssh/id_rsa.pub
- <3>将client端的id_rsa.pub公钥的内容拷贝到server端的~/.ssh/authorized_keys
- <4>设置权限
- # chmod 715 ~/.ssh
- # chmod 664 ~/.ssh/authorized_keys
- # chmod 600 ~/.ssh/id_rsa
- # chmod 600 ~/.ssh/id_rsa.pub
-
- <5>脚本登录,login.sh添加
- ssh username@ServerIP
- <6>设置别名登录,在/etc/profile添加
- alias 13='ssh username@ServerIP'
- 这时候13就是login.sh的别名,执行13就可以免密码登录server。
-
-
- <1>.完成第二种方式后,在~/.ssh/config(没有的话新建即可)里添加
- Host alias #自定义别名
- HostName hostname #替换为你的ssh服务器ip或domain
- Port port #ssh服务器端口,默认为22
- User user #ssh服务器用户名
- IdentityFile ~/.ssh/id_rsa #第一个步骤生成的公钥文件对应的私钥文件(可选)
-
- # emacs ~/.ssh/config
- Host test #自定义别名
- HostName 192.168.2.22
- Port 22
- User ZhangSan
-
- <2>.登录
- # ssh test //终端登录
-
- C-x C-f /ssh:test: //emacs登录
- or
- C-x C-f /ssh:test@192.168.3.44:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。