How to remove an ssh host by name or ip from your authorized hosts file.
ssh-keygen -R {server.example.com}
ssh-keygen -R {ssh.server.ip.address}
How to remove an ssh host by name or ip from your authorized hosts file.
ssh-keygen -R {server.example.com}
ssh-keygen -R {ssh.server.ip.address}
You want to know instantly who has logged in your ssh server. You can be emailed automatically including in .bashrc file of the user you want to monitor following commands:
echo 'ALERT - Root Shell Access (hostname) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" [email protected]
Prefered method if ssh is available.
Another way, if you have SSH:
rsync -aE -e ssh directory user@hostB:target_dir
or from hostB
rsync -aE -e ssh user@hostA:directory target_dir
You can also use the z (--compress) switch to rsync if network throughput is an issue.
With this command you can tunnel your communications if you set software to connect to localhost 127.0.0.1 port 9999
ssh -D 9999 [email protected]
Sometimes when you connect to a ssh server whois host key has changed, ssh client warns you about it. If you want to ignore that advice use StictHostkeyChecking no option.
ssh -o 'StrictHostKeyChecking no' [email protected]
If you want to connect to a ssh server in verbose mode, just and some -v options.
#substitute user for your username and 0.0.0.0 for the ip of the server
ssh -v -v -v [email protected]
Sometimes you need to login to a remote server without typing your password. Really usefull when you want to copy files to remote servers in your bash script routines. To allow the server to do this you have to copy your public key. Here is how to do it:
ssh-copy-id -i .ssh/id_rsa.pub username:[email protected]