Tag: ssh

  • Remove RSA key for ssh authorized hosts file

    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}

  • SSH Access Email Alert for bashrc

    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”)”…

  • Transfer files via ssh with rsync

    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.

  • Ssh port forwarding

    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]  

  • Ignore Ssh host key

    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]

  • Ssh debug

    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]

  • Copy your public key to a remote server

    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]