您的位置:首页 > 运维架构 > Linux

Mac 设置ssh登录云服务器

2018-02-23 22:29 246 查看
执行命令  ssh-copy-id root@hostName
出现以下内容:/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/username/.ssh/id_rsa.pub"/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys输入你的密码:root@hostName's password:*******输入完密码后出现以下内容表示添加成功:Number of key(s) added:        1Now try logging into the machine, with:   "ssh 'root@hostName'"and check to make sure that only the key(s) you wanted were added.

查看远程服务器上的公钥:
cd .ssh/cat authorized_keys会显示以下秘钥内容:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXmMmJthqSFy33QZ2KrlyXcAPhhhj4QkpoV3qe9fvPILRsn+R4dkf4bqxFqp+Z0yhQrWuEhm+Qcjwx6noikQY+kNDHbB7RrQvCHg9bBBlAleFLmEoh7F9UE8/***************************************************************************************************************
此内容跟本地id_rsa.pub的内容相同说明添加成功。
Mac上设置服务器别名登录远程服务器:进入到 .ssh目录下> vim config按照以下格式添加以下内容# 服务器1Host alias-1    HostName IP    Port 22    User root# 服务器2Host alias-2    HostName ip    Port 22    User root保存后就可以使用别名登录(> ssh alias-1) 远程与服务器了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mac linux 服务器 ssh 别名