weiki@WeikideMacBook-Pro ~ % cd ~ weiki@WeikideMacBook-Pro ~ % weiki@WeikideMacBook-Pro ~ % sudo ssh-keygen -t rsa -C '' Password: Generating public/private rsa key pair. Enter file in which to save the key (/var/root/.ssh/id_rsa): Created directory '/var/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /var/root/.ssh/id_rsa Your public key has been saved in /var/root/.ssh/id_rsa.pub The key fingerprint is: SHA256:oFpxxEJFWfXIc4a73rD65QpQ5wKaRwtGabRqmcwkbaA The key's randomart image is: +---[RSA 3072]----+ |. o+=+o... | |.o .+oo . + | |E +.=.= . * + | | * = O = o = | | B = + S o | | . o . . . . | | . . o . | | o * | | .o=.o | +----[SHA256]-----+
# 注意:输入指令后会提醒输入mac生成ssh秘钥时的密码 weiki@WeikideMacBook-Pro ~ % ssh yuan Enter passphrase for key '~/.ssh/id_rsa': Last failed login: Tue Sep 6 11:15:18 CST 2022 Welcome to Service !
# Host后面的内容是服务器别名,用于登录使用,你可以为每个服务器设置一个容易记住的别名 Host ubuntu HostName 150.230.58.131 User ubuntu
Host yuan HostName 192.168.1.112 port 22 User root
ssh 服务器别名 登录
通过在mac终端执行 ssh 服务器别名,连接远程服务器
1 2 3 4 5 6 7 8
# 注意:此处需要远程服务器 weiki@WeikideMacBook-Pro ~ % ssh yuan root@192.168.1.112's password: Last failed login: Tue Sep 6 11:15:18 CST 2022 from 60.177.97.166 on ssh:notty There was 1 failed login attempt since the last successful login. Last login: Tue Sep 6 11:14:42 2022 from 60.177.97.166