How can I change the SSH key use from /etc/ssh/
to ~/.ssh/id_rsa
At the moment when I run ssh -T git@github.com -A -p 22
it finds the key in /etc/ssh/ssh_host_ed25519_key
I also did assign another port on sshd_config
and ssh_config
from 22 to something else.
In systemctl status the new Port is confirmed after restart sshd but ssh is still running on Port 22 at the moment.
I’m thankful for any help
my ssh_config is:
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Port 1234
# Port 443
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
StreamLocalBindUnlink yes
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin no
PermitRootLogin prohibit-password
#StrictModes yes
MaxAuthTries 5
MaxSessions 10
PermitRootLogin forced-commands-only
PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
# PermitEmptyPasswords no
PubkeyAcceptedAlgorithms=+ssh-rsa
AuthenticationMethods publickey keyboard-interactive:pam
# HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
# Change to no to disable s/key passwords
KbdInteractiveAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
UsePAM yes
AllowAgentForwarding yes
AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
#PermitTTY yes
PrintMotd no # pam does that
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/lib/ssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
cat /etc/ssh/ssh_config
# $OpenBSD: ssh_config,v 1.35 2020/07/17 03:43:42 dtucker Exp $
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.
# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.
Port 1234
Host *
ForwardAgent yes
ForwardX11 yes
PasswordAuthentication no
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
#IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
# IdentityFile ~/.ssh/id_ed25519
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
# Ciphers aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# RekeyLimit 1G 1h
UserKnownHostsFile ~/.ssh/known_hosts.d/%k
also I have this in my .zshrc in I’m not really sure if this is so all fine
# GPG
SSH_AGENT_PID=""
SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
# Start ssh-agent if not already running
if ! pgrep -u "$USER" ssh-agent >/dev/null; then
ssh-agent -t 1h >"$XDG_RUNTIME_DIR/ssh-agent.env"
fi
# Source ssh-agent environment variables
if [[ ! -f "$SSH_AUTH_SOCK" ]]; then
source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
fi
if [[ ! -n ${SSH_CONNECTION} ]]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
fi
# Start ssh-agent and redirect output to /dev/null
eval "$(ssh-agent -s)" >/dev/null 2>&1
#
# keychain
keychain -q --absolute --dir "$XDG_RUNTIME_DIR"/keychain
# eval "$(keychain --eval -q gpg ssh id_rsa)"
# eval "$(keychain --eval -q --agents ssh id_rsa)"
ssh_check_agent() {
ssh-agent
ssh -V
}
And I play around with vscodium ~/.ssh/config at the moment I commented all out
# Host *
# Host github.com
# Hostname github.com
# User terashy88
# Port 22
# IdentitiesOnly yes
# PubkeyAcceptedKeyTypes +ssh-rsa
# PreferredAuthentications publickey
# AddKeysToAgent yes
# ForwardAgent yes
# IdentityFile /etc/ssh/ssh_host_ed25519_key
# IdentityFile ~/.ssh/id_rsa
# # Ciphers aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
# # ControlMaster auto
# # ControlPersist yes
# #ControlPath ~/.ssh/sockets/socket-%r@%h:%p
# # RemoteForward remote_agent_socket local_agent_extra_socket
# # RemoteForward remote_agent_ssh_socket local_agent_ssh_socket
# Host gitlab.com
# Hostname altssh.gitlab.com
# User terashy
# IdentitiesOnly yes
# Port 1234
# AddKeysToAgent yes
# ForwardAgent yes
# PubkeyAcceptedKeyTypes +ssh-rsa
# PreferredAuthentications publickey
# IdentityFile ~/.ssh/id_rsa
# # Ciphers aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
# # ControlMaster auto
# # ControlPersist yes
# #ControlPath ~/.ssh/sockets/socket-%r@%h:%p
# # RemoteForward remote_agent_socket local_agent_extra_socket
# # RemoteForward remote_agent_ssh_socket local_agent_ssh_socket
# ssh terashy88@github.com -i ~/.ssh/id_rsa -p 22
# Host github.com
# HostName github.com
# User terashy88
# IdentityFile ~/.ssh/id_rsa.pub
# Port 22