Password authentication
ssh <User>@<HostName>
Configuring key based authentication
-
Generate a separate SSH key in a different file
ssh-keygen -t rsa -b 4096 -f ~/.ssh/<keyname>
-
Add the contents of the local
<keyname>.pub
file to the appropriateauthorized_keys
file(s) on the SSH host.# Method 1 ssh-copy-id -i ~/.ssh/<keyname>.pub <User>@<HostName> # Method 2 scp ~/.ssh/<keyname>.pub <User>@<HostName>:~/.ssh/authorized_keys
-
Open ssh config file and add host information
# Open ssh config vim ~/.ssh/config # Add host information Host <name-of-ssh-host-here> HostName <host-fqdn-or-ip-goes-here> User <your-user-name-on-host> Port <port-to-connect-on-host> # default 22 IdentityFile <path-to-rsa-priavte-key> # e.g. ~/.ssh/<keyname>
-
Connect
ssh <Host>