Linux命令:ssh-copy-id
ssh-copy-id帮助
SSH-COPY-ID() BSD General Commands Manual SSH-COPY-ID() NAME
ssh-copy-id — use locally available keys to authorise logins on a remote machine SYNOPSIS
ssh-copy-id [-f] [-n] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
ssh-copy-id -h | -? DESCRIPTION
ssh-copy-id is a script that uses ssh() to log into a remote machine (presumably using a login password, so password authentication should be enabled, unless you've done some
clever use of multiple identities). It assembles a list of one or more fingerprints (as described below) and tries to log in with each key, to see if any of them are already
installed (of course, if you are not using ssh-agent() this may result in you being repeatedly prompted for pass-phrases). It then assembles a list of those that failed to log
in, and using ssh, enables logins with those keys on the remote server. By default it adds the keys by appending them to the remote user's ~/.ssh/authorized_keys (creating the
file, and directory, if necessary). It is also capable of detecting if the remote system is a NetScreen, and using its ‘set ssh pka-dsa key ...’ command instead. The options are as follows: -i identity_file
Use only the key(s) contained in identity_file (rather than looking for identities via ssh-add() or in the default_ID_file). If the filename does not end in .pub this
is added. If the filename is omitted, the default_ID_file is used. Note that this can be used to ensure that the keys copied have the comment one prefers and/or extra options applied, by ensuring that the key file has these set as pre‐
ferred before the copy is attempted. -f Forced mode: doesn't check if the keys are present on the remote server. This means that it does not need the private key. Of course, this can result in more than one
copy of the key being installed on the remote system. -n do a dry-run. Instead of installing keys on the remote system simply prints the key(s) that would have been installed. -h, -? Print Usage summary -p port, -o ssh_option
These two options are simply passed through untouched, along with their argument, to allow one to set the port or other ssh() options, respectively. Rather than specifying these as command line options, it is often better to use (per-host) settings in ssh()'s configuration file: ssh_config(5). Default behaviour without -i, is to check if ‘ssh-add -L’ provides any output, and if so those keys are used. Note that this results in the comment on the key being the filename
that was given to ssh-add() when the key was loaded into your ssh-agent() rather than the comment contained in that file, which is a bit of a shame. Otherwise, if ssh-add()
provides no keys contents of the default_ID_file will be used. The default_ID_file is the most recent file that matches: ~/.ssh/id*.pub, (excluding those that match ~/.ssh/*-cert.pub) so if you create a key that is not the one you want
ssh-copy-id to use, just use touch(1) on your preferred key's .pub file to reinstate it as the most recent. EXAMPLES
If you have already installed keys from one system on a lot of remote hosts, and you then create a new key, on a new client machine, say, it can be difficult to keep track of
which systems on which you've installed the new key. One way of dealing with this is to load both the new key and old key(s) into your ssh-agent(1). Load the new key first,
without the -c option, then load one or more old keys into the agent, possibly by ssh-ing to the client machine that has that old key, using the -A option to allow agent forward‐
ing: user@newclient$ ssh-add
user@newclient$ ssh -A old.client
user@oldl$ ssh-add -c
... prompt for pass-phrase ...
user@old$ logoff
user@newclient$ ssh someserver now, if the new key is installed on the server, you'll be allowed in unprompted, whereas if you only have the old key(s) enabled, you'll be asked for confirmation, which is your
cue to log back out and run user@newclient$ ssh-copy-id -i someserver The reason you might want to specify the -i option in this case is to ensure that the comment on the installed key is the one from the .pub file, rather than just the filename
that was loaded into you agent. It also ensures that only the id you intended is installed, rather than all the keys that you have in your ssh-agent(1). Of course, you can
specify another id, or use the contents of the ssh-agent(1) as you prefer. Having mentioned ssh-add(1)'s -c option, you might consider using this whenever using agent forwarding to avoid your key being hijacked, but it is much better to instead use
ssh(1)'s ProxyCommand and -W option, to bounce through remote servers while always doing direct end-to-end authentication. This way the middle hop(s) don't get access to your
ssh-agent(1). A web search for ‘ssh proxycommand nc’ should prove enlightening (N.B. the modern approach is to use the -W option, rather than nc(1)). ENVIRONMENT
SSH_COPY_ID_LEGACY
If the SSH_COPY_ID_LEGACY environment variable is set, the ssh-copy-id is run in a legacy mode. In this mode, the ssh-copy-id doesn't check an existence of a private key
and doesn't do remote checks of the remote server versions or if public keys are already installed. SEE ALSO
ssh(1), ssh-agent(1), sshd(8) BSD March 15, 2019 BSD
Linux命令:ssh-copy-id的更多相关文章
- 菜鸟学Linux命令:ssh命令 远程登录
1.查看SSH客户端版本 有的时候需要确认一下SSH客户端及其相应的版本号.使用ssh -V命令可以得到版本号.需要注意的是,Linux一般自带的是OpenSSH: 下面的例子即表明该系统正在使用Op ...
- 关于linux命令ssh的总结
因为项目计算量比较大,需要将任务分布到多台电脑上面运行,因为对于分布式概念不熟,就想到了linux最简单的ssh协议,远程控制其他电脑,然后写shell脚本统一在所有电脑上运行程序.(我的操作系统为U ...
- Linux命令:ssh
ssh介绍 ssh用法 ssh帮助 SSH() BSD General Commands Manual SSH() NAME ssh — OpenSSH SSH client (remote logi ...
- linux命令-ssh {远程登录}
一 命令解释 命令: ssh ssh [-l login_name] [-p port] [user@]hostname
- 每天一个linux命令--ssh的host配置用户名密码
1.在终端输入 cd ~/.ssh/ vi config 输入服务器的用户名和密码 souche@kickseed:~/.ssh$ cat config # 这是跳板机的配置,给跳板机的 IP 起个别 ...
- linux命令--ssh创建隧道
工作应用场景 在工作中,总会连接到各种不能直接访问的环境,所以我们必须使用ssh隧道进行访问. 原理简介 ssh隧道:https://www.jianshu.com/p/20600c91e656
- linux下ssh远程登录/scp远程复制文件/rsync远程同步命令的自动登录
最近需要写一个脚本备份各个服务器上的程序到一个指定服务器上,本来以为查查rsync命令的使用321就能搞定,结果rsync命令要支持自动登 录还是要配置服务和参数,又不确定网上说的配置的行不行,因为都 ...
- SSH Secure Shell Client连接Linux 命令行显示中文乱码问题 和oracle 查询数据中文乱码问题
一.SSH Secure Shell Client连接Linux 命令行显示中文乱码问题 linux 设置系统语言 修改 /etc/sysconfig/i18n 文件,如 LANG="en_ ...
- Linux 使用 ssh 命令远程连接另一台 Linux
用 Linux 系统的 ssh 命令远程连接另一台 Linux 机器的命令 #ssh 用户名@主机名(IP地址) 例: #ssh root@10.41.24.138 ...
- Linux下用命令查看CPU ID以及厂家等信息
Linux下用命令查看CPU ID // 获得CPU IDdmidecode -t 4 | grep ID |sort -u |awk -F': ' '{print $2}' // 获得磁盘IDfdi ...
随机推荐
- [UE4]小地图UI设计
一.新建一个名为TestMiniMap的UserWidget用来使用小地图StaticMiniMap. 二.在左侧“User Created”面板中可以看到除自身以外的其他所有用户创建的UserWid ...
- 矩阵半正定: positive semidefinite
具体定义:https://en.wikipedia.org/wiki/Positive-definite_matrix
- JVM调优常用参数
JVM常用参数配置 -Xmx2048m 最大堆大小 -Xms1024m 初始堆大小 -Xmn1024m 年轻代大小 -XX:SurvivorRatio=8 Eden区与Survivor区的大小比值,设 ...
- [VS工具]如何让#region...#endregion在ashx文件页面上折叠
工具--->选项-->文本编辑器|文件扩展名, 添加后缀名为ashx的文件即可
- RabbitMQ install (Ubuntu)
1. key 1) Online way apt-key adv --keyserver "hkps.pool.sks-keyservers.net" --recv-keys &q ...
- Django中的分页,cookies与session
cookie Cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也不 ...
- linux设置服务器时间同步
yum install -y rdate 服务器请设置 */5 * * * * /usr/bin/rdate -s time-b.nist.gov ubuntu 设定时区:dpkg-reconfigu ...
- Spring中@Component的作用
今天在写程序的时候看见一个以前没有见过的注解(@Component),在网上查找过后,经过实践,决定把它记录下来. 1.@controller 控制器(注入服务) 用于标注控制层,相当于struts中 ...
- VMware扩展Linux根目录磁盘空间(Centos版本)
1.Centos 关机,选择编辑虚拟机设置,硬盘,在实用工具那里选择“扩展”,指定你需要的存储大小 2.启动客户机操作系统Centos,查看磁盘情况 输入指令 fdisk -l 显示结果如下 Disk ...
- Java并发编程:Java Thread 的 run() 与 start() 的区别
1. sleep 和 wait 方法解释 sleep()方法是Thread类里面的,主要的意义就是让当前线程停止执行,让出cpu给其他的线程,但是不会释放对象锁资源以及监控的状态,当指定的时间到了之后 ...