1.ssh-keygen -t rsa

2.ssh-copy-id -i .ssh/id_rsa.pub -p端口 root@xxxxx

执行后发现报错了
[hadoop@oracletest01 ~]$ ssh-copy-id -i .ssh/id_rsa.pub -p9522 hadoop@172.16.1.95
Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh: Could not resolve hostname umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys && (test -x /sbin/restorec: Name or service not known

加引号执行
[hadoop@oracletest01 ~]$ ssh-copy-id -i .ssh/id_rsa.pub ' -p9522 hadoop@172.16.1.95'
The authenticity of host '[172.16.1.95]:9522 ([172.16.1.95]:9522)' can't be established.
RSA key fingerprint is 0a:88:bf:38:3b:67:4d:56:31:bd:5c:d0:28:1e:4d:ea.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[172.16.1.95]:9522' (RSA) to the list of known hosts.
hadoop@172.16.1.95's password:
Now try logging into the machine, with "ssh ' -p9522 hadoop@172.16.1.95'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

posted on 2022-05-16 18:03  xc川  阅读(0)  评论(0)    收藏  举报