Skip to main content

Linux command: ssh-copy-id


ssh-copy-id copy ssh public key to remote host

ssh-copy-id - install your identity.pub public key in a remote machine’s authorized_keys

Syntax

ssh-copy-id [-i [identity_file]] [user@]machine

Copy ssh public key to host 192.168.64.115

[tuyen@rhel5 ~]$ ssh-copy-id -i ~/.ssh/tuyenid_rsa.pub tuyen@192.168.64.115
32
The authenticity of host '192.168.64.115 (192.168.64.115)' can't be established.
RSA key fingerprint is 34:75:a1:bc:f4:15:d6:19:e6:0b:3b:cf:04:74:d0:c3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.64.115' (RSA) to the list of known hosts.
tuyen@192.168.64.115's password:
Now try logging into the machine, with "ssh 'tuyen@192.168.64.115'", and check in:

  .ssh/authorized_keys

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

[tuyen@rhel5 ~]$

ssh to 192.168.64.115 using ssh private key

[tuyen@rhel5 ~]$ ssh -i .ssh/tuyenid_rsa tuyen@192.168.64.115
Last login: Tue Jun 18 11:29:06 2019 from 192.168.64.102
[tuyen@ol7 ~]$

Copy SSH public key from Microsoft Windows to Linux

PS C:\Users\tuyen> type .\.ssh\tuyenid_rsa.pub | ssh tuyen@192.168.64.115 "cat >> .ssh/authorized_keys"

Popular posts from this blog

MSSQL: Fix error 'Consistency validation for SQL Server registry keys'

While installing Microsof SQL Server 2012, I ran into the following error. "The SQL Server registry keys from a prior installation cannot be modified. To continue, see SQL Server Setup documentation about how to fix registry keys." How to fix Replace the D:\x64\FixSqlRegistryKey_x86.exe file with the original file from the ENU\SQLFULL_ENU.iso file downloading from Microsoft Download Center. This ISO file is 4.2GB. So you can click FixSqlRegistryKey_x86.exe to download this file only. After replacing that file, press Re-run to check. All rules are passed.

Powershell: Check Bad Logon

get-aduser -Filter {BadLogonCount -ne 0} -properties * | select SamAccountName,BadLogonCount,BadPasswordTime,BadPwdCount,@{name='badPasswordTimeDT'; expression={[datetime]::fromFileTime($_.badPasswordTime)}} | sort BadPasswordTime | FT

Powershell: Get-History

Get-History - Gets a list of the commands entered during the current session.