ssh configuration
To use ssh from your laptop, you should have the appropriate ssh
configuration file.
- Windows users should be in a terminal in the Windows Subsystem for Linux (WSL).
- Mac users should open the terminal program
- Linux users should open a terminal of choice
The configuration file
You should be in your home directory. The cd command without any argument
will bring you home. The pwd command will tell you the name of that
directory. Here is how it looks for me.
$ cd $ pwd /home/bon $
In that directory there should be a subdirectory called .ssh. You can check
that it's there using the ls command but the ls command does not show
files or directories that start with a dot by default so we will ask for it
explicitly like this
$ ls -d .ssh .ssh $
The -d option means show me the directory, not its contents.
If it shows you nothing like this
$ ls -d .ssh $
you will need to make the directory like this
$ mkdir .ssh $
You should now edit a file called .ssh/config to contain the lines in the
following code block. Perhaps the file is there already, in which case you
should put these lines at the top of the file.
Host git.auc-computing.nl IdentityFile ~/.ssh/id_ed25519 User forgejo AddKeysToAgent yes IdentitiesOnly yes ServerAliveCountMax 30 ServerAliveInterval 5 StrictHostKeyChecking accept-new ControlMaster auto ControlPersist yes ControlPath ~/.ssh/control/%r@%h:%p
The section for advprog is for our Linux server. Breanndán's group is using
it but Lorenzo's is not. You can omit this section if you don't need it.
If you already have a .ssh/config file from a previous course that you no
longer need, you can just rename the file to something else before makng a new
one, as follows.
$ mv .ssh/config .ssh/config.1
If you already have a .ssh/config that you still need and you want to combine
the configuration with that for the AdvProg course, you should probably ask
Breanndán how to do that.
When you have saved the file, make sure it is indeed called config. Some
editors on Windows make the name config.txt.
Here is how to check:
$ ls .ssh config $
This is good. (You may also see othe files there.)
$ ls .ssh config.txt $
If you see the above then rename it.
mv .ssh/config.txt .ssh/config
The keys
If you do not already have a key pair, you can generate it as follows
$ ssh-keygen -t ed25519
You should now see a private key ~/.ssh/id_ed25519 and a public key
~/.ssh/id_ed25519.pub
In order to allow your git to access the Forgejo server you need to visit it
in your browser and put the contents of your public key there. You can check
that you have done this successfully using the following command. You may be
asked for the password for your private key before it gives you output. If you
do get output such as this you are ready to use git with the Forgejo server
to clone, push and pull.
$ ssh -T forgejo@git.auc-computing.nl Hi there, bon! You've successfully authenticated with the key named forgejo, but Forgejo does not provide shell access. If this is unexpected, please log in with password and setup Forgejo under another user. $
(Note that my id is bon and my key is called forgejo.)
If you do not get output like this but your are asked for a password for
forgejo@git.auc-computing.nl then something has gone wrong and you should check
your configuration.