每天⼀个linux命令--ssh的host配置⽤户名密码1、在终端输⼊cd ~/.ssh/
vi configssh命令行
输⼊服务器的⽤户名和密码
souche@kickseed:~/.ssh$ cat config
# 这是跳板机的配置,给跳板机的 IP 起个别名: jump_machine, ⽤户名: owen
Host feature
HostName 172.III.III.III
User XXX
2、⽣成 rsa 公钥和私钥: ssh-keygen -t rsa
tip:如果ssh的⽬录下⾯已经有公钥,就不⽤⽣成了
souche@kickseed:~/.ssh$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/souche/.ssh/id_rsa): 1HyKxJHtKz
1HyKxJHtKz already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in 1HyKxJHtKz.
Your public key has been saved in 1HyKxJHtKz.pub.
The key fingerprint is:
SHA256:PRQmfxrHWuWM5QgqTwd3OIsD8gPq70mf8JCzerVPzw8 souche@kickseed
The key's randomart image is:
+---[RSA 2048]----+
| o =.. o |
| o . Bo= O |
| . +..o.=oB + |
| . o+o+.B |
| . .S.= |
| . .. . |
| .*. .. E |
| .oO.o o . |
| .++ +.. o.. |
+----[SHA256]-----+
souche@kickseed:~/.ssh$
3、 ssh-copy-id -i 密钥⽂件⽤户别名@服务器别名
souche@kickseed:~/.ssh$ ssh-copy-id -i id_rsa.pub souche@feature
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "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
souche@172.17.41.58's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'souche@feature'"
and check to make sure that only the key(s) you wanted were added.
souche@kickseed:~/.ssh$ ssh-copy-id -i id_rsa.pub souche@eva
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论