SSH - Launch a terminal on your session without having to authenticate yourself
Stop typing your SSH password! Learn how to use SSH keys and `ssh-copy-id` to launch a Linux terminal session instantly without having to authenticate yourself every time.
This article is over a year old. The information may be outdated.
This article is part of the SSH - From your first key to remote development series:
- GitHub - Connect your account using SSH and start to work with git@ protocol
- Docker secrets - Using your SSH key during the build process
- Using sftp on the command line, with or without a proxy
- SSH - Autosuggestions with ZSH
- SSH - Launch a terminal on your session without having to authenticate yourself
- How to connect to your hosting server using SSH
- SSH Remote development with VSCode
- Open a DevContainer on a Remote Server with VSCode Remote SSH and ProxyJump
- SSH Config Generator: Wildcard Stanzas, Aliases, and Automated Logins
Changelog

This guide explains how to set up passwordless SSH login to your Linux servers. Learn how to generate an SSH key pair, use ssh-copy-id to securely transfer your public key to the server, and connect without a password. The tutorial also covers using scp for secure file transfers and demonstrates how to create convenient shortcuts for your connections by using a ~/.ssh/config file, allowing you to connect with a simple alias.
Imagine that you regularly need to connect to your Linux server: you need to launch a tool such as Putty, you need to enter your login, password, etc. and carry out various operations before you can access the terminal.
If your password isn't saved in Putty's configuration, you'll have to launch another tool like a password vault; in short, it's annoying.
In this article, we'll look at how to authenticate once and for all on the server using an SSH key.
Two articles that build on this one: How to connect to your hosting server using SSH, applied to a real hosting account, and Master your ssh command and select the host from a list once your ~/.ssh/config holds a dozen aliases.
Information
To illustrate this article, let's assume christophe is the remote username (this is the username for the server, distinct from your local username) and my_blog.be is the remote server address.
Remember to replace these two constants with yours ;-)
TLDR
Create an SSH key, copy it to the remote server and run an SSH connection. Steps 1 and 2 have to be done just once.
Steps to fire in your console:
ssh-keygen -t ed25519 -C "christophe@my_blog.be" -f ~/.ssh/id_ed25519_my_blogssh-copy-id -i ~/.ssh/id_ed25519_my_blog christophe@my_blog.bessh -i ~/.ssh/id_ed25519_my_blog christophe@my_blog.be
In-depth
1. Creating the SSH key
The first thing to do, only once, is to generate an SSH key on your host for the remote server.
By running ssh-keygen -t ed25519 -C "christophe@my_blog.be" -f ~/.ssh/id_ed25519_my_blog (or ssh-keygen -t rsa -C "christophe@my_blog.be" -b 4096 -f ~/.ssh/id_rsa_my_blog for the RSA algorithm):
- You'll create an SSH key for the remote user
christopheon servermy_blog.be. You'll get a private key and a public one, - The key will be saved on your machine and the filename will be
~/.ssh/id_ed25519_my_blogfor the private key (and will have the~/.ssh/id_ed25519_my_blog.pubfor the public one), - The key will be based on the ed25519 algorithm.
2. Copying the key
When this is done, you've to copy the public SSH key to your remote server. To do this, please run ssh-copy-id -i ~/.ssh/id_ed25519_my_blog christophe@my_blog.be. This has to be done just once.
- You'll copy your local SSH public key
id_ed25519_my_blogon themy_blog.beserver, - The key will be added for the remote user
christophe, - You'll have to provide the password of that user when prompted.
Information
The ssh-copy-id command will append your public key to the ~/.ssh/authorized_keys file on the server.
3. Connect to the server
Now, everything is in place, you can run ssh -i ~/.ssh/id_ed25519_my_blog christophe@my_blog.be and it should work because the id_ed25519_my_blog public key was already copied on the server my_blog.be for the user christophe.
Information
You can display or edit the content of the ~/.ssh/authorized_keys file by running cat ~/.ssh/authorized_keys (or vi ~/.ssh/authorized_keys). You can then remove old allowed keys f.i.
Copying files from your host to the server
Now that we can connect to the server so easily, we can f.i. copy files from our host like this:
First we need to specify our local file (or folder) then where to copy it.
Copy files from the server to your host
Now, in the other direction, from the server to your host:
Copying folders
If you need to copy a folder, just add the recursive flag i.e. -r.
For instance, scp -r christophe@my_blog.be:~/backup/ . will copy the entire ~/backup folder from the server into my current, local, folder. Really handy.
Tips
Running ssh from Microsoft Terminal
The SSH experience is much, much better using Microsoft Terminal than the old Putty application.
With Microsoft Terminal, you can work in a full screen mode, you can have a nice background image, you can work with a much better font (the standard one with Putty is awful), use tabs, ...
If you've already experienced Putty, you know what I mean.
Using the config file
As we have seen, when using the ssh or scp command, we need to specify the user name, the name or IP address of the server and the name of the file containing the private key. That's a lot of information to provide, isn't it?
What's more, like me, I can't remember all this information. I just want to connect to my application server and that's it!
It would be nice to be able to ssh my_application and that's it. No? This is the purpose of the ~/.ssh/config file!
To connect on that server, my ssh command looks like this: ssh christophe@my_blog.be -i ~/.ssh/id_ed25519_my_blog. Not easy to remember!
Let's create a ~/.ssh/config file. If the file already exists, just edit it: code ~/.ssh/config.
Add these lines in the file:
Host my_app Hostname my_blog.be User christophe IdentityFile ~/.ssh/id_ed25519_my_blogThis is an SSH configuration block that sets up connection details for a host named 'my_app'. When you SSH to 'my_app', it will automatically use the specified hostname, username, and private key file instead of requiring you to type them each time.
Save the file and go back to the console.
Now, you can just run ssh my_app to make the connection. Pretty easy no?
Want more info? Continue your reading https://linuxize.com/post/using-the-ssh-config-file/
Going further
Once your ~/.ssh/config file starts to grow with aliases, two companion articles are worth a look: SSH - Autosuggestions with ZSH, so you never have to remember an alias again, and Using sftp on the command line if you need the sftp counterpart of scp.
This article is part of the SSH - From your first key to remote development series:
- GitHub - Connect your account using SSH and start to work with git@ protocol
- Docker secrets - Using your SSH key during the build process
- Using sftp on the command line, with or without a proxy
- SSH - Autosuggestions with ZSH
- SSH - Launch a terminal on your session without having to authenticate yourself
- How to connect to your hosting server using SSH
- SSH Remote development with VSCode
- Open a DevContainer on a Remote Server with VSCode Remote SSH and ProxyJump
- SSH Config Generator: Wildcard Stanzas, Aliases, and Automated Logins
Loading comments…




