Task: login to remote host with username and password
Login to host:
-
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
-
Hostname [hostname]
-
Port [port]
-
ForwardAgent [yes|no]
-
ForwardX11 [yes|no]
-
User [login]
Once you have an alias, you can specify the alias name instead of specify all the options as parameters.
-
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
-
</pre>
-
</li>
-
<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>
-
</ul>
-
<h2>Task: copy a local file to a remote host</h2>
-
Copying file to host:
-
<pre lang="shell">
-
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”.
-
scp readme.txt john@wonderland.org:~
Copying file from host:
-
scp scp [remote_user]@[remote_host]:[remote_file_path][local_file_path]
Blogged with the Flock Browser -