SSH: Difference between revisions
No edit summary |
Andre Castro (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
See [[wikipedia:Secure shell]] | See [[wikipedia:Secure shell]] | ||
== Generating ssh key pair == | |||
run: | |||
sshkeygen -t rsa | |||
Answer the menu question | |||
==ssh configuration file== | |||
'''The ssh configuration file makes it a lot simpler to ssh scp or sshfs. | |||
It is especially convenient when you have keys for different servers. It helps you to keep them organized and to ssh into servers with easy to remember shortcuts. | |||
''' | |||
Rather than typing | |||
scp myfile username@host:/path/to/copy/file/to | |||
We can simply do with | |||
scp myfile hostname:/path/to/copy/file/to | |||
===location of the .ssh directory === | |||
On Linux based distros: ''/home/<your username>/.ssh'' | |||
On Mac: ''Users/<your username>/.ssh'' on MacOS. | |||
===create ssh configuration file ~/.ssh/config/== | |||
Create the file: | |||
touch ~/.ssh/config | |||
Open the file in your favorite text editor | |||
insert: | |||
<pre> | |||
Host hostname // name for the shortcut you use to ssh into the server | |||
User usename // ssh user | |||
Hostname 192.168.10.20 // hostname of the server | |||
Port 22 | |||
Identityfile ~/.ssh/id_rsa // change and make sure this is the path to the location of your keys | |||
Serveraliveinterval 30 | |||
</pre> | |||
Now you can use the short cut to ssh/scp/sshfs to that and any other host in in .ssh/config | |||
using only | |||
ssh username@hostname | |||
or even | |||
ssh hostname | |||
==SSFS== | |||
{{:Sshfs}} | |||
[[Category:Cookbook]] |
Revision as of 11:56, 29 September 2019
Secure Shell
An encrypted protocol for a remote shell login.
Generating ssh key pair
run:
sshkeygen -t rsa
Answer the menu question
ssh configuration file
The ssh configuration file makes it a lot simpler to ssh scp or sshfs.
It is especially convenient when you have keys for different servers. It helps you to keep them organized and to ssh into servers with easy to remember shortcuts.
Rather than typing
scp myfile username@host:/path/to/copy/file/to
We can simply do with
scp myfile hostname:/path/to/copy/file/to
location of the .ssh directory
On Linux based distros: /home/<your username>/.ssh
On Mac: Users/<your username>/.ssh on MacOS.
=create ssh configuration file ~/.ssh/config/
Create the file:
touch ~/.ssh/config
Open the file in your favorite text editor
insert:
Host hostname // name for the shortcut you use to ssh into the server User usename // ssh user Hostname 192.168.10.20 // hostname of the server Port 22 Identityfile ~/.ssh/id_rsa // change and make sure this is the path to the location of your keys Serveraliveinterval 30
Now you can use the short cut to ssh/scp/sshfs to that and any other host in in .ssh/config
using only
ssh username@hostname
or even
ssh hostname
SSFS
SSHFS (SSH Filesystem) is a filesystem client for mounting remote directories on your machine, using an SSH connection.
By using it you can access, read, edit files from a remote machine on your local machine, as long as you have an account in the remote machine.
Install
on Debian/Ubuntu
sudo apt update sudo apt install sshfs
on mac
Use homebrew:
brew cask install osxfuse brew install sshfs
If homebrew is not installed, run the installation command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Mounting the Remote File System with sshfs
sshfs command essential parameters:
sshfs user@host:remote_directory local_mount_directory
How to mount:
Create a directory in your local machine, to be use as a mount point
mkdir ~/remote
Mount host remote directory onto the ~/remote directory
ssh user@host:/full/path/to/remote/dir ~/remote
That's it
How to unmount
To unmount the remote dir from the local directory we use the umount
NOT unmount, BUT umount
umount ~/remote