您的位置:首页 > 其它

[SSH] SSH学习笔记 - 远程登录

2015-11-19 14:07 411 查看

1、SSH登陆/登出命令

$ ssh <hostname>              #登入
$ exit                        #登出


known_hosts

每个用户都有自己的known_hosts文件,路径:(username)/.ssh/known_hosts

/etc/目录下的known_hosts文件

2、登录方式:

输入密码登陆

公钥登陆

$ ssh-keygen # 可以加入相关参数选择加密方式,如[-t rsa] #将生成的密钥对中的公钥拷贝到远程服务器上 $ scp /Users/(local_username)/.ssh/id_rsa.pub remote_username@remote_host: #另一种方式:ssh-copy-id # 附:mac下ssh-copy-id command not found解决办法: # $brew install ssh-copy-id #这里的例子里*.pub文件名为id_rsa.pub, 远程主机用户名vagrant, IP:192.168.33.10 $ ssh-copy-id -i ~/.ssh/id_rsa.pub vagrant@192.168.33.10 /usr/local/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/local/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys vagrant@192.168.33.10's password: #此处需要输入密码 Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@192.168.33.10'" and check to make sure that only the key(s) you wanted were added. $

参考资料:

http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: