1. SSH是一种通讯协议,可以实现远程安全登录
$ ssh user@gulong.lexandera.com
$ ssh -p 21 ios@172.16.3.94 //-p 端口号
输入密码即可 在服务器上进行终端操作
2. 免密登录
2.1 $ ssh-copy-id root@gulong.lexandera.com
会将客户端~/.ssh 里面的公钥拷贝到 ~/.ssh/authorized_keys 文件中
注:使用下面的命令解释如上原理
$ ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
2.2 收到将我们的公钥拷贝到~/.ssh/authorized_keys中(如果没有该文件 可以使用命令新建一个)
3. scp工具(ssh远程安全登录)
3.1 get
$ scp localFile root@host:remotePath
$ scp -r localPath root@host:remotePath
3.2 put
$ scp root@host:remoteFile localPath[localFile]
$ scp -r root@host:remotePath localPath
4. ssh-add 的使用 (把专用密钥添加到ssh-agent的高速缓存中)
$ ssh-add #默认添加 ~/.ssh/id_rsa
$ ssh-add ~/.ssh/id_hgl
4.1 -d 删除ssh-agent的密钥
$ ssh-add -d ~/.ssh/id_hgl
4.2 -D 删除所有密钥
$ ssh-add -D
4.3 -L 显示ssh-agent的所有公钥
4.4 -l 显示ssh-agent的所有私钥
4.5 -t 设置时限,超时过期自行卸载
4.6 -x 加锁
4.7 -X 解锁
4.8 -e pkcs11:删除PKCS#11共享库pkcs1提供的钥匙
4.9 -s pkcs11:添加PKCS#11共享库pkcs1提供的钥匙
5. ssh-agent 私钥的管理工具(保存并用于验证)
$ ssh-agent #默认ssh-agent的信息
6. ssh-keyscan 查看公钥
$ ssh-keyscan 172.16.3.94
6.1 -t 指定加密方式
$ ssh-keyscan -t rsa 172.16.3.94
7. ssh-keygen 创建私密钥
$ ssh-keygen -t rsa
8. slogin 同ssh一样用于远程登录
9. ssh-copy-id 分发公钥
$ ssh ios@172.16.3.94
9.1 -i 指定公钥
$ ssh -i ~/.ssh/id_hgl.pub ios@172.16.3.94
10. sftp (有一个help 命令即可)
10.1 连接
$ sftp root@host
$ sftp root@ip
10.2 help 帮助
10.3 pwd 当前目录
10.4 ls 子目录列表
10.5 put 推送文件到sftp服务器上
$ put localFile [remote]
$ put -r localPath [remotePath]
10.6 get 获取sftp服务器上的文件或目录
$ get remoteFile [local]
$ get -r remotePath [localPath]
10.7 bye/quit/exit 退出服务
10.8 ! 进入当前主机目录