出现以下内容:
/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: 1
Now 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
按照以下格式添加以下内容
# 服务器1
Host alias-1
HostName IP
Port 22
User root
# 服务器2
Host alias-2
HostName ip
Port 22
User root
保存后就可以使用别名登录(> ssh alias-1) 远程与服务器了