SSH

j-manu edited this page Mar 27, 2013 · 10 revisions

Copy public key to remote server

cat ~/.ssh/id_dsa.pub | ssh user@hostname "cat - >> ~/.ssh/authorized_keys"

To disable host key checking

Host 192.168.0.*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null

To connect to a host unreachable from current network but reachable from reachable_host's network

ssh -t reachable_host ssh unreachable_host

Use ssh-copy-id to install your public key in a remote machine's authorized_keys. Also takes care of the permissions of the remote user's .ssh and .ssh/authorized_keys.


SOCKS 5 Proxy

ssh -D 8080 -Nf  user@hostname

Opens socks5 proxy in localhost on port 8080. Set SOCKS proxy in Firefox to use this.


Running remote commands

ssh -t manu "source /etc/profile; source ~/.bashrc; cd rails_root_dir; bundle exec rails c production"

This example opens a Rails console remotely to the machine with the ssh config specified.