[Valid RSS]

SSH Cheat Sheet

Task: login to remote host with username and password

Login to host:

  1. ssh  -l  [login] -p [port]

Task: login to remote host using a configured alias

First of all you need to configure the alias. The SSH configuration file is normlly stored in ~/.ssh/config. This is an example.

host
  1.  Hostname [hostname]
  2.  Port [port]
  3.  ForwardAgent [yes|no]
  4.  ForwardX11 [yes|no]
  5.  User [login]

Once you have an alias, you can specify the alias name instead of specify all the options as parameters.

  1. ssh [alias]

Task: login to remote host using key authentication

  • Put your private key in ~/.ssh/id_rsa
  • Ensure nobody can access it. After all it’s your private key.
  • Transfer your public key in your remote host home directory
  • On the remote host append the public key to the list of authorized ones with the following command.
    cat [public_key_file] >> ~/.ssh/authorized_keys
    1. </pre>
    2. </li>
    3. <li>Pay attention to the fact that the authorized_key file should be writeable only by the owner. If you forget that, the key based authentication will definitely fail.</li>
    4. </ul>
    5. <h2>Task: copy a local file to a remote host</h2>
    6. Copying file to host:
    7. <pre lang="shell">
    8. scp [local_file] [remote_user]@[remote_host]:[path]

    Copy the local file “readme.txt” on your remote host folder (don’t forget the “~”) using the “john” username. Let’s suppose the remote host is called “wonderland.org”.

    1. scp readme.txt john@wonderland.org:~

    Copying file from host:

    1. scp scp [remote_user]@[remote_host]:[remote_file_path][local_file_path]
    Blogged with the Flock Browser

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>