date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,638,661,752,000
We can change the default port settings at /etc/ssh/sshd_config but the manual does not provide any information if we can assign different ports for different users? Is setting up multiple ports for a service possible?
Yes. Example of a server which listens on ports 666 and 667, and only allows users whose names start with "a" through port 666: Port 666 Port 667 Match LocalPort 666 AllowUsers a* Go read about all those directives in the sshd_config(5) manpage.
Is it possible to configure different ssh ports for different users?
1,638,661,752,000
I have a Stretch-based desktop with IPv6 disabled, both as parameter in the kernel. I have the ssh client from the openssh-client package, version 1:7.6p1-2.0nosystemd1, installed. Upon debugging a DNS resolving problem, I did notice nonetheless the ssh client is doing IPv6 DNS related queries as the included tcpdump logs show. My question, is, how to disable that behaviour? PS. I am not asking whether it is a good or bad idea, just asking how to do it in a system that has already all IPv6 services disabled. tcpdump logs when doing the commands ssh server1 ; ssh server2. # tcpdump -n port 53 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on wlan0, link-type EN10MB (Ethernet), capture size 262144 bytes 02:53:37.479073 IP 192.168.1.5.58296 > 192.168.1.1.53: 61011+ A? server1.home. (30) 02:53:37.479100 IP 192.168.1.5.58296 > 192.168.1.1.53: 4719+ AAAA? server1.home. (30) 02:53:37.487504 IP 192.168.1.1.53 > 192.168.1.5.58296: 61011 NXDomain* 0/1/0 (69) 02:53:37.493279 IP 192.168.1.1.53 > 192.168.1.5.58296: 4719 NXDomain* 0/1/0 (69) 02:53:37.493428 IP 192.168.1.5.60276 > 192.168.1.1.53: 31390+ A? server1. (25) 02:53:37.493455 IP 192.168.1.5.60276 > 192.168.1.1.53: 50392+ AAAA? server1. (25) 02:53:37.527879 IP 192.168.1.1.53 > 192.168.1.5.60276: 31390 NXDomain 0/1/0 (100) 02:53:37.535417 IP 192.168.1.1.53 > 192.168.1.5.60276: 50392 NXDomain 0/1/0 (100) 02:53:38.447390 IP 192.168.1.5.36155 > 192.168.1.1.53: 39363+ A? server1.home. (30) 02:53:38.447412 IP 192.168.1.5.36155 > 192.168.1.1.53: 4430+ AAAA? server1.home. (30) 02:53:38.455743 IP 192.168.1.1.53 > 192.168.1.5.36155: 39363 NXDomain* 0/1/0 (69) 02:53:38.461492 IP 192.168.1.1.53 > 192.168.1.5.36155: 4430 NXDomain* 0/1/0 (69) 02:53:38.461606 IP 192.168.1.5.39311 > 192.168.1.1.53: 45400+ A? server1. (25) 02:53:38.461631 IP 192.168.1.5.39311 > 192.168.1.1.53: 872+ AAAA? server1. (25) 02:53:38.493714 IP 192.168.1.1.53 > 192.168.1.5.39311: 45400 NXDomain 0/1/0 (100) 02:53:38.500353 IP 192.168.1.1.53 > 192.168.1.5.39311: 872 NXDomain 0/1/0 (100) Proof IPv6 is disabled in kernel/grub: $ cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-4.10.5-antix.3-amd64-smp root=UUID=00c17984-859f-4197-8bd8-b346ddd092bd ro iommu=1 intel_iommu=on iommu=pt ip6.disable=1 intremap=no_x2apic_optout radeon.pcie_gen2=0 And also in sysctl: $ cat /etc/sysctl.conf | grep ipv6 net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 Also /etc/gai.conf is changed to prioritize IPv4.
To disable IPv6 name queries in your sshclient, you can: call ssh in the command line with the -4 option to only operate and do queries in IPv4; define then an alias as: alias ssh=`ssh -4` If you have system administration of the machine, you can also disable the IPv6 functions/DNS queries in the ssh client system wide configuration file editing /etc/ssh/ssh_config and adding the following configuration parameter: AddressFamily inet From man ssh_config: AddressFamily Specifies which address family to use when connecting. Valid arguments are ''any'', ''inet'' (use IPv4 only), or ''inet6'' (use IPv6 only).
Disabling openssh client AAAA DNS queries
1,638,661,752,000
I had openssh-server working on my dedicated server running proxmox, but everytime I tried to upgrade anything I got this error: dpkg:error processing package openssh-server (--configure): subprocess installed post-installation script returned error exit status 10 So I read on forums that I should uninstall and purge openssh-server and install it again therefore I ran proxmox shell which doesn't need ssh to connect to server and remove openssh-server. Now I cannot install it and I don't have ssh access to my server. I tried this: $ dpkg --configure -D 777 openssh-server ... D000400: checking breaker openssh-sftp-server:amd64 virtbroken <none> D000400: checking virtbroken openssh-server Setting up openssh-server (1:7.4p1-10+deb9u3) ... D000002: fork/exec /var/lib/dpkg/info/openssh-server.postinst ( configure ) dpkg: error processing package openssh-server (--configure): subprocess installed post-installation script returned error exit status 10 D000001: ensure_diversions: same, skipping Errors were encountered while processing: openssh-server I also tried removing openssh-server* from /var/lib/dpkg/info and installing it again I didn't have any success. My OS is Debian Stretch and I installed proxmox kernel on it. How can I install openssh-server with these situation?
At last I couldn't config openssh-server but I edit my /etc/apt/sources.list and added these lines: (As my server is in Hetzner Co.) deb http://mirror.hetzner.de/debian/packages jessie main contrib non-free deb http://mirror.hetzner.de/debian/security jessie/updates main contrib non-free deb http://mirror.hetzner.de/debian/packages jessie-updates main contrib non-free Then I installed the latest previous version of openssh-server which it was on jessie mirror. Like this: apt update apt remove openssh-client openssh-sftp-server openssh-server apt clean apt install openssh-client=1:6.7p1-5+deb8u4 apt install openssh-sftp-server=1:6.7p1-5+deb8u4 apt install openssh-server=1:6.7p1-5+deb8u4 You can also check any package versions you can install by this: apt-cache showpkg package apt-cache showpkg openssh-server
subprocess installed post-installation script returned error exit status 10
1,638,661,752,000
I have been maintaining an old Linux server (CentOS 6.5) for long term. I access that Linux server by ssh with 'pub key auth'. Now I just bought a new Windows (win10 or 11 not sure) laptop and installed ‘Git for win 2.33’, when I try to ssh from the new lap top as usual, I got: $ ssh -i ~/.ssh/id_rsa.bridge_to_home -p 5122 -vv shaozr@{ip addr} OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021 debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolve_canonicalize: hostname 27.115.62.170 is address debug1: Connecting to 27.115.62.170 [27.115.62.170] port 5122. debug1: Connection established. debug1: identity file /c/Users/43141/.ssh/id_rsa.bridge_to_home type -1 debug1: identity file /c/Users/43141/.ssh/id_rsa.bridge_to_home-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.8 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: compat_banner: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002 debug2: fd 4 setting O_NONBLOCK debug1: Authenticating to 27.115.62.170:5122 as 'shaozr' debug1: load_hostkeys: fopen /c/Users/43141/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /c/Users/43141/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: local client KEXINIT proposal debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256 debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: compression ctos: none,[email protected],zlib debug2: compression stoc: none,[email protected],zlib debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug2: peer server KEXINIT proposal debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: host key algorithms: ssh-rsa,ssh-dss debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: MACs ctos: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: MACs stoc: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: compression ctos: none,[email protected] debug2: compression stoc: none,[email protected] debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: diffie-hellman-group-exchange-sha256 debug1: kex: host key algorithm: (no match) Unable to negotiate with 27.115.62.170 port 5122: no matching host key type found. Their offer: ssh-rsa,ssh-dss This is weird. I can still ssh to that linux from my old PC, and I can git clone via ssh (to famous git repo provider) from my new laptop. It seems that both sides are 'ssh OK', but why the CentOS6.6 rejects my id_ras key from ‘Git for win 2.33’ ?
Just ran into this at work on a new Windows machine with a new Cygwin installed that installed OpenSSH 9. Turns out that in 8.something, the OpenSSH team disabled the older ssh-rsa encryption algorithms by default. (See https://www.openssh.com/releasenotes.html) It's not the server rejecting you; it's that your newer client isn't willing to speak ssh-rsa, which is all the older OpenSSH daemons can speak. You can instruct your client to re-enable them, but that's a workaround. You're going to need to upgrade the ssh daemons on your servers. The ssh-rsa algos were disabled because they are insecure and easily cracked with modern hardware. So, the workaround is to make a ssh config file on your client, in $HOME/.ssh/config, and in it, you put something like this: Host HOSTNAME HostKeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa Replace HOSTNAME with a regex that matches the hostname you are connecting to.
Old Linux rejects my ssh id_rsa key from newly installed windows
1,638,661,752,000
This question stems out of curiosity, but lets say I currently have an ssh session with a remote computer, and I run the following command: sudo systemctl stop ssh and after running: systemctl status ssh to verify the status of the service, it seems to be inactive(dead) why am I still able to execute any commands remotely? again this is not a formal problem, I am just curious Thank You for your time
When you connect, the SSH daemon (e.g. sshd) forks at least once. From now on your connection is handled by a separate process, not the listening daemon itself. systemctl stop ssh stops the listening daemon, so new SSH connections cannot be established. Existing connections survive because forked processes survive. This is an example snippet from pstree -u: systemd-+-… … |-sshd---sshd---sshd(kamil)---bash---… … The first sshd is the daemon running as root. The second one is a forked elevated process, still retaining root's power. The third one has dropped root's power, it belongs to me (kamil). Stopping (killing) the daemon process does not affect the other two (yes, I have tested).
Why does running sudo systemctl stop ssh over ssh not immediately terminate the ssh session
1,638,661,752,000
on my host server I have my user with generated private and public keys. I have copied public key value to my remote server authorized_keys file. I have mapped new docker container instance to use the .ssh folder as a volume and set network to the host's network. -v /home/jenkins/.ssh:/home/jenkins/.ssh --network host' Now I try to SSH authenticate myself inside the container towards the remote computer. ssh -vvv -o StrictHostKeyChecking=no [email protected] My user does not have SSH pass phrase. Output on the SSH server side: sshd: Failed none for jenkins from 10.7.148.219 port 42058 ssh2 sshd: Failed password for jenkins from 10.7.148.219 port 42058 ssh2 Output on the client side: + ssh -vvv -o 'StrictHostKeyChecking=no' [email protected] OpenSSH_8.6p1, OpenSSL 1.1.1l 24 Aug 2021 debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolve_canonicalize: hostname 10.7.175.143 is address debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/root/.ssh/known_hosts' debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/root/.ssh/known_hosts2' debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling debug3: ssh_connect_direct: entering debug1: Connecting to 10.7.175.143 [10.7.175.143] port 22. debug3: set_sock_tos: set socket 3 IP_TOS 0x48 debug1: Connection established. ................................. debug1: Authentications that can continue: publickey,password,keyboard-interactive debug3: start over, passed a different list publickey,password,keyboard-interactive debug3: preferred publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/id_rsa debug3: no such identity: /root/.ssh/id_rsa: No such file or directory debug1: Trying private key: /root/.ssh/id_dsa debug3: no such identity: /root/.ssh/id_dsa: No such file or directory debug1: Trying private key: /root/.ssh/id_ecdsa debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /root/.ssh/id_ecdsa_sk debug3: no such identity: /root/.ssh/id_ecdsa_sk: No such file or directory debug1: Trying private key: /root/.ssh/id_ed25519 debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory debug1: Trying private key: /root/.ssh/id_ed25519_sk debug3: no such identity: /root/.ssh/id_ed25519_sk: No such file or directory debug1: Trying private key: /root/.ssh/id_xmss debug3: no such identity: /root/.ssh/id_xmss: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup keyboard-interactive debug3: remaining preferred: password debug3: authmethod_is_enabled keyboard-interactive debug1: Next authentication method: keyboard-interactive debug2: userauth_kbdint debug3: send packet: type 50 debug2: we sent a keyboard-interactive packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,password,keyboard-interactive debug3: userauth_kbdint: disable: no info_req_seen debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: debug3: authmethod_is_enabled password debug1: Next authentication method: password debug1: read_passphrase: can't open /dev/tty: No such device or address debug3: send packet: type 50 debug2: we sent a password packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,password,keyboard-interactive debug2: we did not send a packet, disable method debug1: No more authentication methods to try. [email protected]: Permission denied (publickey,password,keyboard-interactive). Can I somehow authenticate my self from the docker container?
From your debug output, you could see that since you're running the ssh command as root, it searches for the ssh keys in root's home folder instead of jenkins home folder. debug1: Trying private key: /root/.ssh/id_rsa debug3: no such identity: /root/.ssh/id_rsa: No such file or directory You should provide the location of your private key by adding the -i <identity_file> flag to your ssh command.
can't SSH from docker container to remote server
1,638,661,752,000
Description I have created an ssh connection between my MS-Windows PC and Raspberry Pi. To do so I followed the following steps: Step 1: Somehow get the IP address of the Raspberry Pi. It should be something like this: 192.168.1.52 Step 2: Open a shell and access the Raspberry Pi via ssh: ssh [email protected] You will need the password. Step 3: In the home directory of the remote pc use these commands: mkdir .ssh Step 4: Secure the ssh connection via private/public key. In the local pc use this commands: ssh-keygen -f .ssh/fede_windows -t rsa -b 4096 If your local machine is Linux based run this line: chmod 600 .ssh/fede_windows # if linux Finally: scp .ssh/fede_windows.pub [email protected]:.ssh Step 5: In the remote pc use these commands: sudo nano /etc/ssh/sshd_config and modify the following lines of the config file: ChallengeResponseAuthentication no PasswordAuthentication no UsePAM no Finally: sudo systemctl reload sshd Step 6: In the remote computer use these commands: cat ~/.ssh/fede_windows.pub >> ~/.ssh/authorized_keys chmod 700 ~/.ssh/ chmod 600 ~/.ssh/* Step 7: In the local computer run this command to log in to the remote one: ssh -i .ssh/fede_windows [email protected] Problem: When I perform all these steps again in my Ubuntu Pc by generating this time a key named fede_ubuntu, it looks like that I am able to ssh my Raspberry Pi no matter what I insert in the command: ssh -i .ssh/fede_xyz [email protected] It works all the time and this is not supposed to happen since it should be restricted only to the key I just created. If I switch to my Windows machine everything works as expected and only if I specify the right key works. Question: Would you be able to suggest a possible reason of this issue and how to fix it please? EDIT: By typing the following command ssh -i .ssh/key_that_does_not_exits -v [email protected] I get: Warning: Identity file .ssh/key_that_does_not_exits not accessible: No such file or directory. OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f 31 Mar 2020 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to 192.168.1.52 [192.168.1.52] port 22. debug1: Connection established. debug1: identity file /home/federico/.ssh/id_rsa type -1 debug1: identity file /home/federico/.ssh/id_rsa-cert type -1 debug1: identity file /home/federico/.ssh/id_dsa type -1 debug1: identity file /home/federico/.ssh/id_dsa-cert type -1 debug1: identity file /home/federico/.ssh/id_ecdsa type -1 debug1: identity file /home/federico/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/federico/.ssh/id_ecdsa_sk type -1 debug1: identity file /home/federico/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /home/federico/.ssh/id_ed25519 type -1 debug1: identity file /home/federico/.ssh/id_ed25519-cert type -1 debug1: identity file /home/federico/.ssh/id_ed25519_sk type -1 debug1: identity file /home/federico/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /home/federico/.ssh/id_xmss type -1 debug1: identity file /home/federico/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Raspbian-10+deb10u2+rpt1 debug1: match: OpenSSH_7.9p1 Raspbian-10+deb10u2+rpt1 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 192.168.1.52:22 as 'pi' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:hC5w2kDxgHH5eFRY1vOJaS7ipPR+8OWX2tkkEZbF194 debug1: Host '192.168.1.52' is known and matches the ECDSA host key. debug1: Found key in /home/federico/.ssh/known_hosts:1 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: Will attempt key: federico@federico RSA SHA256:E96Hu2Ee+IyAuoZ06GxTvo+ZmAkzqfihbAKkFqxU1AU agent debug1: Will attempt key: /home/federico/.ssh/id_rsa debug1: Will attempt key: /home/federico/.ssh/id_dsa debug1: Will attempt key: /home/federico/.ssh/id_ecdsa debug1: Will attempt key: /home/federico/.ssh/id_ecdsa_sk debug1: Will attempt key: /home/federico/.ssh/id_ed25519 debug1: Will attempt key: /home/federico/.ssh/id_ed25519_sk debug1: Will attempt key: /home/federico/.ssh/id_xmss debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering public key: federico@federico RSA SHA256:E96Hu2Ee+IyAuoZ06GxTvo+ZmAkzqfihbAKkFqxU1AU agent debug1: Server accepts key: federico@federico RSA SHA256:E96Hu2Ee+IyAuoZ06GxTvo+ZmAkzqfihbAKkFqxU1AU agent debug1: Authentication succeeded (publickey). Authenticated to 192.168.1.52 ([192.168.1.52]:22). debug1: channel 0: new [client-session] debug1: Requesting [email protected] debug1: Entering interactive session. debug1: pledge: network debug1: client_input_global_request: rtype [email protected] want_reply 0 debug1: Remote: /home/pi/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding debug1: Remote: /home/pi/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding debug1: Sending environment. debug1: Sending env LC_ADDRESS = it_IT.UTF-8 debug1: Sending env LC_NAME = it_IT.UTF-8 debug1: Sending env LC_MONETARY = it_IT.UTF-8 debug1: Sending env LC_PAPER = it_IT.UTF-8 debug1: Sending env LANG = en_US.UTF-8 debug1: Sending env LC_IDENTIFICATION = it_IT.UTF-8 debug1: Sending env LC_TELEPHONE = it_IT.UTF-8 debug1: Sending env LC_MEASUREMENT = it_IT.UTF-8 debug1: Sending env LC_TIME = it_IT.UTF-8 debug1: Sending env LC_NUMERIC = it_IT.UTF-8 Last login: Sun Aug 22 22:26:00 2021 from 192.168.1.197
From your log: debug1: Next authentication method: publickey debug1: Offering public key: federico@federico RSA SHA256:E96Hu2Ee+IyAuoZ06GxTvo+ZmAkzqfihbAKkFqxU1AU agent debug1: Server accepts key: federico@federico RSA SHA256:E96Hu2Ee+IyAuoZ06GxTvo+ZmAkzqfihbAKkFqxU1AU agent debug1: Authentication succeeded (publickey). This means that a key from your SSH agent is being used. I'm assuming it's a valid key that you have recently used and that you have either manually added to the agent, or that has been added due to using AddKeysToAgent yes in your ~/.ssh/config file. Remove all identities from your SSH agent and try again: ssh-add -D. Alternatively, add IdentityAgent none to your SSH configuration or use ssh -o IndentityAgent=none when you call ssh. You may also benefit from using IdentitiesOnly yes in your SSH configuration, which will give you more control over exactly which identities are offered to an SSH server. See the documentation for this option in ssh_config(5).
Why am I able to SSH a remote machine even with the wrong keys?
1,638,661,752,000
I am using Openwrt here, I find that I can login remote host without a password or private key. I added a SSH-Keys (public key) in System->Administration tab, this public key is a key pair with the remote host's private key. I thought that ssh client must using private key to login, situation here seems it used a public key? SSH debug log: root@OpenWrt:~# ssh <HOST> -p 443 -vvv OpenSSH_6.8p1, OpenSSL 1.0.2e 3 Dec 2015 debug1: Reading configuration data /etc/ssh/ssh_config debug2: ssh_connect: needpriv 0 debug1: Connecting to <HOST> [<HOST>] port 443. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.8 debug1: Remote protocol version 2.0, remote software version dropbear_2011.54 debug1: no match: dropbear_2011.54 debug2: fd 3 setting O_NONBLOCK debug3: put_host_port: [<HOST>]:443 debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:1 debug3: load_hostkeys: loaded 1 keys from [<HOST>]:443 debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected],arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1,[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,3des-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes256-cbc debug2: kex_parse_kexinit: aes128-ctr,3des-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes256-cbc debug2: kex_parse_kexinit: hmac-sha1,hmac-md5 debug2: kex_parse_kexinit: hmac-sha1,hmac-md5 debug2: kex_parse_kexinit: none debug2: kex_parse_kexinit: none debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug1: kex: server->client aes128-ctr hmac-sha1 none debug1: kex: client->server aes128-ctr hmac-sha1 none debug1: sending SSH2_MSG_KEXDH_INIT debug2: bits set: 1004/2048 debug1: expecting SSH2_MSG_KEXDH_REPLY debug1: Server host key: ssh-rsa SHA256:H/MgAoUz/bDefD1KiHrrpPjo8BOqXqUDPd0bhlJr4eE debug3: put_host_port: [<HOST>]:443 debug3: put_host_port: [<HOST>]:443 debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:1 debug3: load_hostkeys: loaded 1 keys from [<HOST>]:443 debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:1 debug3: load_hostkeys: loaded 1 keys from [<HOST>]:443 debug1: Host '[<HOST>]:443' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts:1 debug2: bits set: 1008/2048 debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: root@palm-webos (0x77d53ee0), debug2: key: /root/.ssh/id_rsa ((nil)), debug2: key: /root/.ssh/id_dsa ((nil)), debug2: key: /root/.ssh/id_ecdsa ((nil)), debug2: key: /root/.ssh/id_ed25519 ((nil)), debug1: Authentications that can continue: publickey debug3: start over, passed a different list publickey debug3: preferred publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: root@palm-webos debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 279 debug2: input_userauth_pk_ok: fp SHA256:wfA3yC7+sEIeTSQp6NUmP14XlgEX5WuJyVoL9m3WrX4 debug3: sign_and_send_pubkey: RSA SHA256:wfA3yC7+sEIeTSQp6NUmP14XlgEX5WuJyVoL9m3WrX4 debug1: Authentication succeeded (publickey). Authenticated to <HOST> ([<HOST>]:443). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Entering interactive session. debug2: callback start debug2: fd 3 setting TCP_NODELAY debug3: ssh_packet_set_tos: set IP_TOS 0x10 debug2: client_session2_setup: id 0 debug2: channel 0: request pty-req confirm 1 debug2: channel 0: request shell confirm 1 debug2: callback done debug2: channel 0: open confirm rwindow 24576 rmax 32768 debug2: channel_input_status_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug2: channel_input_status_confirm: type 99 id 0 debug2: shell request accepted on channel 0 I searched for id_rsa file and found nothing root@OpenWrt:~# find / -type f -name id_rsa Left is the problem one, right is normal ssh login using private key: Update: Update ssh debug to level 3 and a comparison picture with normal private key login.
debug3: sign_and_send_pubkey: RSA SHA256:wfA3yC7+sEIeTSQp6NUmP14XlgEX5WuJyVoL9m3WrX4 debug1: Authentication succeeded (publickey). Authenticated to <HOST> ([<HOST>]:443). says that you are using public key authentication, that succeeded. The key does not have a path, most probably because it is offered by the ssh-agent. Update: Update ssh debug to level 3 and a comparison picture with normal private key login. In the image, you compare connection using one private key with connection using different private key. The difference is that the first one is sending public key test at first to verify if it can succeed, the second sends the signature directly without this test. What is the difference is described in the RFC 4252, Section 7
Why can I login remote host without password or private key?
1,638,661,752,000
I've configured several systems manually. I'd like to start working more systematically now. I configure openssh-server more strictly than Debian defaults, to exclude password-guessing attacks. So I worked on some sequences for system configuration. I notice SSH is a problem. When you install openssh-server on Debian, it immediately starts running with the default configuration (unlike Fedora). Question: suggest a sequence for securely configuring SSH which avoids this race condition. E.g. I want to use SSH on one desktop system, where other users have never needed SSH access. They don't use any remote access to the system. Working to enforce "secure passwords" would waste our time. Limiting remote access in /etc/sshd_config is simpler and better security. I have also sometimes created local accounts for test purposes. (Embarrassingly, I had one such account fall victim to an SSH worm).
Sequence Create an empty file /etc/ssh/sshd_not_to_be_run, if openssh-server is not installed. (Some options for scripting this condition here) Install openssh-server Edit /etc/ssh/sshd_config as desired Remove /etc/ssh/sshd_not_to_be_run Run systemctl enable ssh systemctl systemctl restart ssh or a well-tested equivalent. restart appears to work ok if the service wasn't already started (compare condrestart try-restart). I notice systemctl enable --now does not start the service, if it was already enabled but not running. Options which were not used These are the other options I discovered and decided not to use. This issue has been discussed at debian-users. Sadly the race condition is not solved. A Debian maintainer suggests configuring policy-rc.d to block the invoke-rc.d ssh start call in the package postinstall. There are clunky details details are clunky, but achievable. Unfortunately this is not really true; it doesn't prevent a race condition. policy-rc.d is not relevant to the update-rc.d ssh enable command which the package also runs. This would be exposed by a power failure or system crash at the wrong time. Notice the openssh-server package suggests ufw :). Ubuntu created ufw as a very simple firewall. I'm somewhat puzzled what "user stories" it was originally written for, but in Ubuntu Oneiric it's used to support a concept of trusted networks, like Windows does. You could install ufw and abuse it to block SSH until you've configured it. Of course this assumes there isn't a configuration where ufw treats the current network as trusted. Heh. I dislike this option for two further reasons. I've been writing sequences as individual ansible roles. Firstly, this option means an SSH role is messing with firewall configuration. Even when the host didn't otherwise need a firewall. (Or if you're writing these sequences incrementally... and perhaps you have an existing firewall which doesn't even have commands like ufw does which are so convenient for automation). A second wart is that ansible roles are designed to be idempotent. You can update your ansible roles and run a single command to apply them all. It will highlight the tasks that actually changed the system v.s. those that already matched. You make restarting services conditional on whether their configuration was modified (as opposed to already matching). It doesn't fit the model to unconditionally toggle the firewall configuration on & off. You could make this conditional on openssh-server not being installed already, but that's not one of the common idioms you see in the documentation examples. You either need ansible 2.2, to apply check_mode: yes to service name=ssh, or you need to script around dpkg. EDIT: You can just create a symlink to mask ssh.service, before installing the package. I don't mind assuming systemd is used , however automating this would be somewhat annoying. I think the package install would return an error, and leave the package installed but with a state of "unconfigured". It's not hard to "reconfigure" the package after fixing the config. The annoyance is that you have to ignore the error during the package install. You risk continuing when there might have been another error. It's particularly a problem for proper automation, but it can also be annoying if you're following a manual checklist. Create an sshd_config in advance. I tested this and it was not overwritten. Problem: the packaged sshd_config was nowhere to be seen. (I tried this on Fedora as well - they give you a warning and creates sshd_config.rpmnew). If you wanted to base your config on the packaged configuration... it becomes complex even if the package didn't lose its file. One of the answers linked to by @Ipor-Sircer points out that Debian can be monkey-patched using dpkg-divert. debootstrap uses this on start-stop-daemon. We could divert update-rc.d, in combination with option 1. Now we're writing two temporary scripts... Less intrusively, we could try to use it to divert the installation of /etc/sshd_config. This would allow preserving the packaged config file for inspection, and by explicitly preventing the overwrite it might be more robust. Unfortunately it turns out dpkg-divert doesn't affect sshd_config, because the file is dynamically generated by a postinstall script. This probably explains the lack of a warning in option 5. The last point was explained to me by someone who pointed at the package source code. I then noticed a reference to sshd_not_to_be_run in the postrm script.
Configuring my sshd securely (with automation) [duplicate]
1,638,661,752,000
With this loop we sequential update on all servers (server list = consul members | grep awk {'print $2'} | cut -d ":" -f1) the package consul. for i in $(consul members | grep awk {'print $2'} | cut -d ":" -f1) ; do sshpass -p $PASSWORD ssh -oStrictHostKeyChecking=no -q root@$i "hostname && yum clean all && yum -y update consul && systemctl restart consul.service" ; done We have over 1000 servers, so we wish to run the sshpass in parallel on 10 servers. I found GNU Parallel for this task. Howo use it with sshpass and make sure no server (server list) is done twice?
Indeed, pssh sounds like the better solution. If you must use parallel it should be fairly simple: pipe the hostnames one per line into a single command that uses {} as a placehold. Eg: consul members | ... awk {'print $2'} | cut -d ":" -f1 | parallel -j 10 sshpass -p "$PASSWORD" ssh -oStrictHostKeyChecking=no -q root@{} "hostname && yum clean all && yum -y update consul && systemctl restart consul.service" Using sshpass should not make any difference. Test it first with a simple command such as just hostname.
GNU Parallel and sshpass with server list in a loop
1,638,661,752,000
I face the following situation on one machine with 64bit Mint 17.3 Cinnamon: $ sudo apt-get install openssh-server Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: openssh-client:i386 openssh-sftp-server Suggested packages: ssh-askpass:i386 libpam-ssh:i386 keychain:i386 monkeysphere:i386 rssh molly-guard monkeysphere Recommended packages: ncurses-term ssh-import-id The following packages will be REMOVED: openssh-client The following NEW packages will be installed: openssh-client:i386 openssh-server openssh-sftp-server 0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded. Need to get 928 kB of archives. After this operation, 1 418 kB of additional disk space will be used. Do you want to continue? [Y/n] n Abort. I don't understand why it wants to remove the 64bit openssh-client and install 32bit instead. /etc/apt/sources.list #deb cdrom:[Linux Mint 17.3 _Rosa_ - Release amd64 20151115]/ trusty contrib main non-free /etc/apt/sources.list.d folder contains many PPAs: doublecmd.list esmska.list getdeb.list google-chrome.list graphics-drivers-ppa-trusty.list inkscape_dev-stable-trusty.list mono-xamarin.list nijel-phpmyadmin-trusty.list n-muench-programs-ppa2-trusty.list official-package-repositories.list official-source-repositories.list ondrej-php-trusty.list otto-kesselgulasch-gimp-trusty.list playonlinux.list spideroakone.list spotify.list steam.list strukturag-libde265-trusty.list ubuntu-sdk-team-ppa-trusty.list ubuntu-touch-coreapps-drivers-daily-trusty.list unit193-encryption-trusty.list videolan-master-daily-trusty.list virtualbox.list wfg-0ad-trusty.list wine.list apt-get update Reading package lists... Done I can see no errors. apt-get -o Debug::pkgProblemResolver=true install openssh-server Reading package lists... Done Building dependency tree Reading state information... Done Starting pkgProblemResolver with broken count: 0 Starting 2 pkgProblemResolver with broken count: 0 Done The following extra packages will be installed: openssh-client:i386 openssh-sftp-server Suggested packages: ssh-askpass:i386 libpam-ssh:i386 keychain:i386 monkeysphere:i386 rssh molly-guard monkeysphere Recommended packages: ncurses-term ssh-import-id The following packages will be REMOVED: openssh-client The following NEW packages will be installed: openssh-client:i386 openssh-server openssh-sftp-server 0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded. Need to get 928 kB of archives. After this operation, 1,418 kB of additional disk space will be used. Do you want to continue? [Y/n] n Abort. apt-cache policy openssh-client openssh-server openssh-client: Installed: 1:6.6p1-2ubuntu2.6 Candidate: 1:6.6p1-2ubuntu2.6 Version table: *** 1:6.6p1-2ubuntu2.6 0 100 /var/lib/dpkg/status 1:6.6p1-2ubuntu2.4 0 500 http://archive.ubuntu.mirror.dkm.cz/ trusty-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 1:6.6p1-2ubuntu1 0 500 http://archive.ubuntu.mirror.dkm.cz/ trusty/main amd64 Packages openssh-server: Installed: (none) Candidate: 1:6.6p1-2ubuntu2.4 Version table: 1:6.6p1-2ubuntu2.4 0 500 http://archive.ubuntu.mirror.dkm.cz/ trusty-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 1:6.6p1-2ubuntu1 0 500 http://archive.ubuntu.mirror.dkm.cz/ trusty/main amd64 Packages
Per your apt-cache policy output, you have openssh-client 1:6.6p1-2ubuntu2.6 installed, but this doesn't correspond to any URL, and the version number is not the same as the server version number. The Debian ssh packages require the client and server versions to match exactly. So, it's clear why apt wants to remove the amd64 version of openssh-client you have installed. What is less clear is why it is trying to install the i386 version of openssh-client. So, just do: apt-get purge openssh-client And then install both openssh-client and openssh-server. apt-get install openssh-client openssh-server PS: Explanation from Julian Andres Klode on #debian-apt. juliank> faheem: It would have to downgrade the amd64 version, which is forbidden. But the :i386 one is apparently allowed to satisfy dependencies on other architectures (Multi-Arch: foreign), so it can install that instead. Satisfying dependencies on other architectures seems a bit wacky, but I suppose an i386 client might work with an amd64 server.
Why installing openssh-server would remove openssh-client?
1,638,661,752,000
I am logged into my Debian machine. I want my friend to get in via SSH. He comes to authenticate as the user friend. My machine asks him for a password. He does not know the password. I want to be able to let him in by running a command my session (root) that is already authenticated. I do not want to tell him the password, or change the password. I just want to open the door for this session. Is there just a way to tell Linux "OK, this authentication that is trying to come in right now is good. Let it in."?
You could potentially do this using screen (which you may need to install) and SSH keys. You need to log in as root and then run 'screen -US friend' (install if necessary), run whatever commands you need to do, and the detach from that (using 'Ctrl-A D') to leave it running. Then in /root/.authorized_keys add your friend's id_rsa.pub or id_dsa.pub key. With that, your friend can then ssh to root@yourmachine, then run 'screen -UDR friend' to reattach to the screen terminal, see what you've already done in it, and run Once your friend has finished, remove their key from /root/.authorized_keys right away. The only problem with this is that you will not be able to see what your friend is doing. Better would be for you to su to root in a terminal window and then use something like VNC, LogMeIn or TeamViewer to share your desktop to your friend so you can watch what they are doing.
Open the SSH Door to a Knocking Friend
1,638,661,752,000
About SSH - if in the client is executed the command: ssh-keygen -R <hostname|ip> The public key(s) of the server is/are removed from the ~/.ssh/known_hosts file Now, in the server: Question: Is there a command to delete the public key of the client stored in the ~/.ssh/authorized_keys file?. It to be used mostly for server environments
You could use sed : sed -i '/ *username@client-hostname *$/d' ~/.ssh/authorized_keys man ssh talk about editing the file, it seems there's no specific tool to achieve this simple task
Command to delete a public key from the ~/.ssh/authorized_keys file?
1,596,664,921,000
I am trying to forward a gpg-agent Unix socket to a remote machine. I have tried the following two versions of the remote forwarding command: A: ssh -vvv -N -R ~/.gnupg/S.gpg-agent:~/.gnupg/S.gpg-agent.extra {HOST} B: ssh -vvv -N -R ~/.gnupg/S.gpg-agent:/home/{USER}/.gnupg/S.gpg-agent.extra {HOST} They both report successful remote forwarding after initial ssh connection. However, option A's socket fails with debug1: connect_next: host ~/.gnupg/S.gpg-agent.extra ([unix]:~/.gnupg/S.gpg-agent.extra): No such file or directory when an actual data connection is attempted on the remote machine with gpg-connect-agent /bye while option B's socket works fine. I want to know whether it is possible to do local home directory expansion with ssh remote forwarding command. If not, why?
The ~ must be expanded by some program. Usually this program is the shell. The sshd daemon doesn't feed the path to a shell and doesn't expand the path. But you don't need an expansion for the current users home directory as it is the working directory anyway. Try ssh -vvv -N -R ~/.gnupg/S.gpg-agent:${HOME}/.gnupg/S.gpg-agent.extra {HOST} Edit: This works because the working directory on the host (not on the client) is always the home directory of the target user. The ssh server doesn't expand ~ of environment variables, but it should be possible to execute code on the host to create a link or symlink to a known location that can be used by the ssh server. Edited as suggested by Kusalananda
Does OpenSSH >=7.2 support local-side tilde expansion for remote Unix socket forwarding
1,596,664,921,000
I am trying to setup a vpn via openssh. I am running the client on Arch Linux. The version of the client is OpenSSH_7.7p1, OpenSSL 1.1.0h 27 Mar 2018. The ssh server is on Ubuntu 17.10 on Google Cloud, version OpenSSH_7.5p1 Ubuntu-10ubuntu0.1, OpenSSL 1.0.2g 1 Mar 2016. In the server configuration I have enabled all kinds of forwarding as well as the PermitTunnel option. I have restarted the sshd daemon. I had also disabled apparmor just in case. No selinux is running. I also did modprobe tun just in case (although openvpn for instance works without issues). The server has ip forwarding enabled on both Google Cloud and Ubuntu level. ufw is disabled and the Google firewall is completely opened. First I tried connecting with this command: sudo ssh -i ssh_key -w any:any root@ip -vvv -o Tunnel=point-to-point The above fails and the debug output from ssh around the point of failure is: debug1: Authentication succeeded (publickey). Authenticated to xxxxxxxx. debug1: Requesting tun unit 1 in mode 1 debug1: sys_tun_open: tun1 mode 1 fd 4 Tunnel device open failed. Could not request tunnel forwarding. debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 As the above failed, I thought I should create the tun devices first. This is what I did: On the client: sudo ip tuntap add tun1 mode tun sudo ip link set tun1 up sudo ip addr add 172.32.0.1/24 peer 172.32.0.2 dev tun1 On the server: sudo ip tuntap add tun1 mode tun sudo ip link set tun1 up sudo ip addr add 172.32.0.2/24 peer 172.32.0.1 dev tun1 But this fails again in the same exact way. I tried running an sshd server on my local machine and connect to localhost. But then again it failed in the same manner. I tried local port forwarding and it worked. How can one properly setup a vpn with openssh? I thoroughly searched the net but nothing helped there.
I have the same problem on my Arch Linux. ArchLinux is installed on the client and server. The version of openssh is 7.7p1-1. As a temporary solution, I installed openssh version 7.6p1-2
Cannot create OpenSSH tunnel
1,596,664,921,000
Are there any configs for OpenSSH server to disallow weak (e.g. <2048 bits) RSA keys? I'm aware of PubkeyAccetedAlgorithms which can disallow specific key types, incl. rsa-sha2, as a whole.
The RequiredRSASize option was added in OpenSSH 9.1, released on October 4th, 2022: ssh(1), sshd(8): add a RequiredRSASize directive to set a minimum RSA key length. Keys below this length will be ignored for user authentication and for host authentication in sshd(8). ssh(1) will terminate a connection if the server offers an RSA key that falls below this limit, as the SSH protocol does not include the ability to retry a failed key exchange.
OpenSSH: how to disallow weak (<2048 bits) RSA keys
1,596,664,921,000
I have been trying to establish a connection to a remote server controlled by a hosting company. I provided them with my .pub file and they say that it has been added to the authorized_keys file on the server. My connection always seems to default back to password authentication. I am in contact with the hosting company as I believe this to be a problem on their end, but I want to ensure that I have done everything properly. The output of ssh -vvv is as follows: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "aqua2.nmsrv.com" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to aqua2.nmsrv.com [208.70.245.240] port 22. debug1: Connection established. debug1: identity file /home/karst/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/karst/.ssh/id_rsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1-hpn14v5 debug1: match: OpenSSH_6.7p1-hpn14v5 pat OpenSSH* compat 0x04000000 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to karstsrv.nmsrv.com:22 as 'karst' debug3: hostkeys_foreach: reading file "/home/karst/.ssh/known_hosts" debug3: record_hostkey: found key type ECDSA in file /home/karst/.ssh/known_hosts:4 debug3: load_hostkeys: loaded 1 keys from karstsrv.nmsrv.com debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 debug3: send packet: type 20 debug1: SSH2_MSG_KEXINIT sent debug3: receive packet: type 20 debug1: SSH2_MSG_KEXINIT received debug2: local client KEXINIT proposal debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c debug2: host key algorithms: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],ssh-rsa-cert-v01 @openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: compression ctos: none,[email protected],zlib debug2: compression stoc: none,[email protected],zlib debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug2: peer server KEXINIT proposal debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 debug2: host key algorithms: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519 debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected] debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected] debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: compression ctos: none,[email protected] debug2: compression stoc: none,[email protected] debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: [email protected] debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug3: send packet: type 30 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug3: receive packet: type 31 debug1: Server host key: ecdsa-sha2-nistp256 SHA256:/3mOxCAhieumccJeTzF2bUHKWMVmcvOgZAd6Ut5gBXc debug3: hostkeys_foreach: reading file "/home/karst/.ssh/known_hosts" debug3: record_hostkey: found key type ECDSA in file /home/karst/.ssh/known_hosts:4 debug3: load_hostkeys: loaded 1 keys from karstsrv.nmsrv.com debug3: hostkeys_foreach: reading file "/home/karst/.ssh/known_hosts" debug3: record_hostkey: found key type ECDSA in file /home/karst/.ssh/known_hosts:5 debug3: load_hostkeys: loaded 1 keys from 208.70.245.240 debug1: Host 'karstsrv.nmsrv.com' is known and matches the ECDSA host key. debug1: Found key in /home/karst/.ssh/known_hosts:4 debug3: send packet: type 21 debug2: set_newkeys: mode 1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug3: receive packet: type 21 debug2: set_newkeys: mode 0 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS received debug2: key: /home/karst/.ssh/id_rsa (0x5583355be270) debug3: send packet: type 5 debug3: receive packet: type 6 debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug3: send packet: type 50 debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,keyboard-interactive debug3: start over, passed a different list publickey,keyboard-interactive debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/karst/.ssh/id_rsa debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,keyboard-interactive debug2: we did not send a packet, disable method debug3: authmethod_lookup keyboard-interactive debug3: remaining preferred: password debug3: authmethod_is_enabled keyboard-interactive debug1: Next authentication method: keyboard-interactive debug2: userauth_kbdint debug3: send packet: type 50 debug2: we sent a keyboard-interactive packet, wait for reply debug3: receive packet: type 60 debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 1 As far as I can tell it seems that OpenSSH is not able to find my id_rsa file located at ~/.ssh/id_rsa. This file definitely exists and appears to have the proper permissions as evidenced by the output of ls -al: total 72 drwx------ 2 karst karst 4096 Jan 30 12:34 . drwxr-xr-x 54 karst karst 4096 Jan 30 12:34 .. -rw------- 1 karst karst 401 Dec 14 11:33 authorized_keys -rw------- 1 karst karst 1679 Jan 16 14:32 google_compute_engine -rw-r--r-- 1 karst karst 400 Jan 16 14:32 google_compute_engine.pub -rw-r--r-- 1 karst karst 444 Jan 17 12:42 google_compute_known_hosts -rw------- 1 karst karst 1675 Nov 15 13:51 id_rsa -rw-r--r-- 1 karst karst 400 Nov 15 13:51 id_rsa.pub -rw------- 1 karst karst 6212 Jan 25 13:26 known_hosts What is going on here? What does "key_load_public: no such file or directory" mean?
You see several times in the debug log that your ssh client did load your id_rsa key: debug1: identity file /home/karst/.ssh/id_rsa type 1 ... debug2: key: /home/karst/.ssh/id_rsa (0x5583355be270) and offers it to the server ... debug1: Offering RSA public key: /home/karst/.ssh/id_rsa ... and there's hope ... debug1: Authentications that can continue: publickey,keyboard-interactive ... until: debug3: remaining preferred: password When the SSH server decided to not accept your key for authentication. Perhaps the destination permissions were not correct, or the key was not loaded to the authorized_keys file, or the SSH daemon is not configured to accept key authentication, etc. You are right to chase down the hosting company with your debug logs, showing that they are not accepting key authentication. What, exactly, does "key_load_public: no such file or directory" mean? From https://superuser.com/a/962895/513541: it talks about the file mentioned below, not above. You have just the regular public keys, but you do not have the SSH certificates for them (presumably because you just don't need them). OpenSSH however will always try to load the associated .pub-cert file for each identity key.
ssh not able to read ~/.ssh/id_rsa
1,596,664,921,000
I am trying to connect to a server I have previously connected to. However newer version of OpenSSH does not use DSA keys. I get the following error when trying to connect: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ***RSA*** key sent by the remote host is SHA256:mxVLlJWwlY7pRm1nhOksy0eS4KIQbAE8nv7x0p3Ds8Q. Please contact your system administrator. Add correct host key in /Users/john/.ssh/known_hosts to get rid of this message. Offending ***DSA*** key in /Users/john/.ssh/known_hosts:25 ***RSA*** host key for example.com has changed and you have requested strict checking. Host key verification failed. I have figured out that the problem is that DSA key is stored in known_hosts but there is no RSA key yet. Adding the RSA key fixes the problem. I think the message is misleading, the RSA host key did not change. I would expect OpenSSH to inform me that there is no RSA key yet and offer me to add the key. It should also check DNS for the key and show Matching host key fingerprint found in DNS. message (which I have set up). Is it worth reporting to OpenSSH as a bug?
I think the message is misleading, the RSA host key did not change. The message is valid. The key in your known_hosts is DSA and the server sends RSA, they differ and it is wrong. Since OpenSSH 6.8 the server sends all the keys after authentication to simplify the hostkey rotation or deprecation. If you have new enough client and server, go on with workaround, temporary accept the DSA keys and let the client pick up the new ones: ssh -oHostKeyAlgorithms=+ssh-dss your_remote_host if the server has older version, you need to do that manually as you explain in the question. This also needs a client configured to accept the new keys: UpdateHostKeys yes.
Why does SSH reports possible man-in-the-middle with different key types?
1,596,664,921,000
it is necessary to update the openssh server to the latest version, since everything is closed, it has come to manually assemble it ./configure --prefix=/usr --with-pam --with-selinux --with-privsep-path=/var/lib/sshd/ --with-kerberos5=/etc/krb5.conf --sysconfdir=/etc/ssh --with-default-path=/usr/bin --with-pid-dir=/run && make the version was updated, the installation was successful, but I can't restart it I get an error Bad configuration option: GSSAPIKexAlgorithms this data is contained in the file /etc/crypto-policies/back-ends/openssh.config GSSAPIKexAlgorithms gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1- I tried to comment, but it didn't help, how to fix it? version OpenSSH_9.3p1
"GSSAPIKexAlgorithms" isn't a standard Openssh server feature. It's apparently part of a feature added to Openssh by some Linux vendors. For example, here is the patch page for Debian's version of Openssh 9.2. "gssapi.patch" on that page adds support for GSSAPIKexAlgorithms and some other configuration options. I'm not familiar enough with Oracle Linux to find information on their Openssh patches. This page is the Openssh team's version of the sshd configuration options, and you'll notice that it doesn't describe "GSSAPIKexAlgorithms" or certain other GSS options. If you're not using GSSAPI, you could edit /etc/crypto-policies/back-ends/openssh.config to "comment out" the options which sshd doesn't like. To comment out a line, place a "#" (pound sign) at the beginning of the line. After editing the file, run "sshd -t" to test whether the configuration files have any problems. Then restart the sshd process to enable the changes. If you are using GSSAPI and need those options to work, then you should look to your Linux vendor for an updated version of Openssh server, or else the source code changes that they're making to add support for the GSSAPI features. If necessary, you could try downloading the Debian patch that was referenced above, and try to apply it to the Openssh source code that you downloaded.
How to restart sshd after assembly?
1,596,664,921,000
This is a kind of follow-up question to this question: ssh, start a specific shell, and run a command on the remote machine?, except more-specifically regarding ash, and focused on the fact that sourcing a .bashrc file as part of starting the shell in the ssh session doesn't work for me. I'm on an embedded Linux device which has a busybox version of sh and ash, but there is no bash. We share a common username (root), and a common execution environment. I'd like to have a few custom aliases and a custom PS1 Prompt String 1 variable, however. Here is an example normal ssh session. Note that I'm using sshpass to pass my password to ssh, with my password stored in the ~/pw file. You can see that the default shell is -sh and there are no aliases. The default PS1 prompt string also shows no path. $ sshpass -f ~/pw ssh [email protected] [root@device]$ echo $0 -sh [root@device]$ alias [root@device]$ The device has no bash, but it does have ash, which apparently is bash-like. So, I want to make that my shell as I ssh in. I also want to copy Ubuntu's default ~/.bashrc file, located in /etc/skel/.bashrc on the Ubuntu machine I'm ssh-ing from, to the device at /tmp/.bashrc so I can source it, and I want my ssh command to do that. I can't copy to ~/.bashrc on the remote device because the home dir is read-only. I tried the following, but get the following error: cmd: sshpass -f ~/pw scp /etc/skel/.bashrc [email protected]:/tmp/.bashrc \ && sshpass -f ~/pw ssh -t [email protected] '. /tmp/.bashrc' result: Connection to 192.168.0.2 closed. No ssh session was established. I then tried the following command, with the following result, showing that sourcing did not work, although the ash shell was entered. $ sshpass -f ~/pw scp /etc/skel/.bashrc [email protected]:/tmp/.bashrc \ && sshpass -f ~/pw ssh -t [email protected] '. /tmp/.bashrc; ash' ~ # echo $0 ash ~ # alias ~ # I can run . /tmp/.bashrc manually now though, and it works fine. Notice how after sourcing, which works, I have an improved prompt string and new aliases: ~ # . /tmp/.bashrc ash: /tmp/.bashrc: line 16: shopt: not found ash: /tmp/.bashrc: line 24: shopt: not found ash: /tmp/.bashrc: line 111: shopt: not found root@device:~# alias l='ls -CF' alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '"'"'s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'"'"')"' la='ls -A' ll='ls -alF' You also see the ash errors from line 16, 24, and 111 due to shopt not being found. Even if I comment those out in the .bashrc file I send over, the results as shown above are still the same. How can I get my above command to work? I'd like it to ssh in, set the shell to something more like bash, and source my /tmp/.bashrc file I scp'ed over. On a similar embedded device which does have bash installed, this cmd works perfectly, as I document in my repo here: sshpass -f ~/pw scp /etc/skel/.bashrc [email protected]:/tmp \ && sshpass -f ~/pw ssh -t [email protected] 'bash --rcfile /tmp/.bashrc' For bash, using bash --rcfile /tmp/.bashrc at the end of the ssh cmd is what I need. But, for the device withOUT bash, I need help getting this behavior with ash or similar.
Why are you running ash? A system with busybox is unlikely to have two different shells. (It's technically possible that /bin/sh is not the same shell as /bin/ash, but it would be a very unlikely setup on an embedded device.) Apart from a few simple aliases or functions, very little of the typical content of .bashrc is likely to work in ash (or in any shell that isn't bash). Things that won't work include shopt, key bindings, prompt settings, any function that uses non-POSIX extension, any alias that refers to commands not present on the embedded device. … ssh -t [email protected] '. /tmp/.bashrc; ash' You're reading /tmp/.bashrc in the original shell, then running a different shell program. That different program doesn't inherit any of the shell's internal settings such as aliases. It's a completely different problem from ssh, start a specific shell, and run a command on the remote machine? which is about reading .profile, which sets environemnt variables, which are inherited. BusyBox's ash reads commands from the file whose name is in $ENV when it starts interactively. (BusyBox's sh can be either ash or hush; since you have an ash command, yours is ash.) So you can set ENV to the name of the file where you want to read commands. … ssh -t [email protected] 'export ENV=/tmp/.bashrc; sh -i'
ssh, start a specific shell (ash), and source your environment on the remote machine
1,596,664,921,000
I have a set of RPi4s (7 of them) running Ubuntu 20.04. One of them is the gui, from where I run commands. There are 3 managers and 3 workers (/etc/hosts is properly set up on all of them). Initially, they all have a user with the same name and password in all of them. I want to set up SSH in a single script run once in the gui (gui0), so that then I have paswordless SSH. The gui* machines should have acces to all; manager* machines should have access to managers and workers; and workers should only be able to access other workers. The reason for that is that I'm going to set up storage with GlusterFS (and a few other things), so the machines need to be able to talk between them. I developed a script, which more or less works: Depending on the time that I sleep between some of the commands, there are more keys that are actually copied, but I'm already sleeping huge times, and still don't reach 100%. Script: #!/bin/bash ################################################################################ ## source ## ################################################################################ source lib/libalx/sh/sysexits.sh; ## This provides EX_USAGE=64 ################################################################################ ## definitions ## ################################################################################ ARGC=0; guis="gui0"; managers="manager0 manager1 manager2"; workers="worker0 worker1 worker2"; all_machines="${guis} ${managers} ${workers}"; gui_accessible_machines="${all_machines}"; manager_accessible_machines="${managers} ${workers}"; worker_accessible_machines="${workers}"; ################################################################################ ## functions ## ################################################################################ ## XXX: Pair calls to this function with "unset SSHPASS"!!! function read_ssh_password() { echo "This script will set up keyless ssh." echo "After this script, ssh will not accept passwords again." echo "Enter the current password for ssh connections." read -s -p "Password to use: " SSHPASS; echo; export SSHPASS; } function create_ssh_keys() { for remote in ${all_machines}; do echo " SSH-KEYGEN ${remote};" sshpass -e ssh ${remote} " ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa; "; done } function distribute_ssh_keys_to() { local accessible_machines="$1"; # local ssh_opts="-o PreferredAuthentications=keyboard-interactive"; # ssh_opts="${ssh_opts} -o PubkeyAuthentication=no"; for remote in ${accessible_machines}; do echo " SSH-COPY-ID $(cat /etc/hostname) ${remote};" sshpass -e ssh-copy-id -i ~/.ssh/id_rsa.pub ${remote} \ 2>&1 | grep -e WARNING -e ERROR -e added; sleep 60; done } function distribute_ssh_keys_from() { # ssh_opts="-o PreferredAuthentications=keyboard-interactive"; # ssh_opts="${ssh_opts} -o PubkeyAuthentication=no"; local machines="$1"; local accessible_machines="$2"; for remote in ${machines}; do sshpass -e ssh ${remote} " $(declare -fg); export SSHPASS=${SSHPASS}; distribute_ssh_keys_to \"${accessible_machines}\"; unset SSHPASS; "; sleep 300; done sleep 300; } function distribute_ssh_keys() { distribute_ssh_keys_from "${guis}" "${gui_accessible_machines}"; distribute_ssh_keys_from "${managers}" "${manager_accessible_machines}"; distribute_ssh_keys_from "${workers}" "${worker_accessible_machines}"; for remote in ${all_machines}; do ssh ${remote} " $(declare -fg); secure_ssh; "; sleep 60; done } function secure_ssh() { :; ## TODO } function create_distribute_ssh_keys() { read_ssh_password; create_ssh_keys; sleep 300; distribute_ssh_keys; unset SSHPASS; } ################################################################################ ## main ## ################################################################################ function main() { create_distribute_ssh_keys; } ################################################################################ ## run ## ################################################################################ argc=$#; if [ ${argc} -ne ${ARGC} ]; then echo "Illegal number of parameters (Requires ${ARGC})"; exit ${EX_USAGE}; fi main; Output: ubuntu@gui0:~$ ./bin/setup_ssh.sh This script will set up keyless ssh. After this script, ssh will not accept passwords again. Enter the current password for ssh connections. Password to use: SSH-KEYGEN gui0; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-KEYGEN manager0; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-KEYGEN manager1; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-KEYGEN manager2; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-KEYGEN worker0; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-KEYGEN worker1; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-KEYGEN worker2; Generating public/private rsa key pair. /home/ubuntu/.ssh/id_rsa already exists. Overwrite (y/n)? n SSH-COPY-ID gui0 gui0; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID gui0 manager0; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID gui0 manager1; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID gui0 manager2; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID gui0 worker0; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID gui0 worker1; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID gui0 worker2; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID manager0 manager0; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID manager0 manager1; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID manager0 manager2; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID manager0 worker0; Number of key(s) added: 1 SSH-COPY-ID manager0 worker1; SSH-COPY-ID manager0 worker2; /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system. SSH-COPY-ID manager1 manager0; SSH-COPY-ID manager1 manager1; SSH-COPY-ID manager1 manager2; SSH-COPY-ID manager1 worker0; SSH-COPY-ID manager1 worker1; SSH-COPY-ID manager1 worker2; SSH-COPY-ID manager2 manager0; SSH-COPY-ID manager2 manager1; SSH-COPY-ID manager2 manager2; SSH-COPY-ID manager2 worker0; SSH-COPY-ID manager2 worker1; SSH-COPY-ID manager2 worker2; SSH-COPY-ID worker0 worker0; SSH-COPY-ID worker0 worker1; SSH-COPY-ID worker0 worker2; SSH-COPY-ID worker1 worker0; SSH-COPY-ID worker1 worker1; SSH-COPY-ID worker1 worker2; SSH-COPY-ID worker2 worker0; SSH-COPY-ID worker2 worker1; SSH-COPY-ID worker2 worker2; I expect to receive always either a line saying the number of keys added, or some ERROR or WARNING. But there are cases where I only receive INFO lines (which I discard as noise with grep). As you can see, the first few work (it shows a WARNING because it's not the first time I run it, so the keys were already installed on a previous run, but that's fine), then some start failing, and then all of them fail. If I reduce the sleep time, it starts failing earlier. As an example of what happens without grep: SSH-COPY-ID manager0; worker0; /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'worker0'" and check to make sure that only the key(s) you wanted were added. SSH-COPY-ID manager0; worker1; /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub" SSH-COPY-ID manager0; worker2; /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'worker2'" and check to make sure that only the key(s) you wanted were added. Why is it failing so erratically?
I can't see why you've got the long sleep statements spread around, and I'm not convinced I've traced your program's flow correctly. However, looking at the requirements, you need The gui* machines should have access to all; manager* machines should have access to managers and workers; and workers should only be able to access other workers So GUI → GUI Managers Workers Managers → Managers Workers Workers → Workers Something like this then. You'll want to add your own progress updates and exit status, I'm sure, but this barebones should get you running. #!/bin/bash # guis=(gui0) managers=(manager0 manager1 manager2) workers=(worker0 worker1 worker2) # Grab the password # IFS= read -rsp "Master password: " sshpass && echo # First, GUI to everything # if [[ ! -f "$HOME/.ssh/id_rsa" ]] || [[ ! -f "$HOME/.ssh/id_rsa.pub" ]] then # Start clean rm -f "$HOME/.ssh/id_rsa" "$HOME/.ssh/id_rsa.pub" ssh-keygen -t rsa -b 4096 -f "$HOME/.ssh/id_rsa" -P "" fi for dst in "${guis[@]}" "${managers[@]}" "${workers[@]}" do # Using the password we entered at the beginning, copy the keys everywhere SSHPASS=$sshpass sshpass -ev ssh-copy-id -o StrictHostKeyChecking=no -i "$HOME/.ssh/id_rsa" "$dst" done # Now generate a key on each host in turn # for dst in "${managers[@]}" "${workers[@]}" do # Ensure the target is clean and then generate a new key ssh -n "$dst" 'rm -f .ssh/id_rsa .ssh/id_rsa.pub' ssh -n "$dst" 'ssh-keygen -t rsa -b 4096 -f .ssh/id_rsa -P ""' done # Grab each host's key pair # for src in "${managers[@]}" "${workers[@]}" do scp -p "$src:.ssh/id_rsa" "$HOME/.ssh/id_rsa.$src" scp -p "$src:.ssh/id_rsa.pub" "$HOME/.ssh/id_rsa.$src.pub" done # Push each Manager key out to the Managers and Workers # for src in "${managers[@]}" do for dst in "${managers[@]}" "${workers[@]}" do ssh-copy-id -i "$HOME/.ssh/id_rsa.$src" "$dst" done done # Push each Worker key out to the Workers # for src in "${workers[@]}" do for dst in "${workers[@]}" do ssh-copy-id -i "$HOME/.ssh/id_rsa.$src" "$dst" done done # Now fix up the "authenticity of host" warnings by connecting everywhere # for src in "${managers[@]}" do for dst in "${managers[@]}" "${workers[@]}" do ssh -n "$src" ssh -n -o StrictHostKeyChecking=no "$dst" id >/dev/null done done for src in "${workers[@]}" do for dst in "${workers[@]}" do ssh -n "$src" ssh -n -o StrictHostKeyChecking=no "$dst" id >/dev/null done done # Delete the unwanted key pairs from this host # for src in "${managers[@]}" "${workers[@]}" do rm -f "$HOME/.ssh/id_rsa.$src" "$HOME/.ssh/id_rsa.$src.pub" done # All done # exit 0 Notice that everything is controlled from the client (gui0), and during the process none of the Managers or Workers initiates a copy of any file to any other machine.
ssh-copy-id working erratically in a loop in a script (cluster)
1,596,664,921,000
Suppose I am using Match Group and inside of that block I am using ForceCommand is there a way to refer to the name of the connecting user or the user's home folder in a similar fashion AuthorizedKeysFile can use the tokens %h, %U, and %u? Alternatively does ForceCommand get the contents of these tokens in some other form? That is, if I use /etc/ssh/sshrc to output environment variables I get to see $USER, $HOME et cetera; is it appropriate/allowed to use those inside ForceCommand? In case it matters: I am using version 8.2p1.
The command is run as the use you are connecting to. Thus, you have $USER, $LOGNAME, $HOME, etc. set to that same user. There's no problem in using them. The command itself is run with the user shell (usually bash, so /bin/bash -c 'your_forcecommand'), so you can include such variables in the ForceCommand and they will be expanded by the shell. sshd_config states: The command is invoked by using the user's login shell with the -c option. You can find in OpenSSH code that it sets PATH, USER, LOGNAME and HOME.
After Match Group block, in ForceCommand can I somehow refer to the username (etc.) in a generic fashion?
1,596,664,921,000
First, I want to be clear, I am not asking about just using public key authentication without a prompt. I have a use case where a user must only be allowed access through SSH public key authentication. Logging in via password on a serial terminal is something I want disabled for this user. I am building my own linux kernel, so the user is created with a home directory that contains an authorized_keys file. In /etc/shadow, the user has an entry with no password: <username>:!:.... My sshd_config contains PasswordAuthentication no, PermitEmptyPasswords yes but even still the user is denied with the correct private key identity file matching that user's ~/.ssh/authorized_keys file. UsePAM no is not supported by this version of the SSH server (at least that is what is reported). All ownership and permissions on the user's files/folder server-side have been validated. After looking at what I think is the openSSH server (sshd) code, it checks for a locked account in the /etc/shadow password file: https://github.com/openssh/openssh-portable/blob/V_7_4_P1/auth.c#L141 This leads me to believe that it is folly to try it this way, I should set a password and disable serial logins another way. This makes intuitive sense but I wanted to get confirmation that the kernel (and openssh) is designed to not allow a user to log in unless as password has been set. Is there any official documentation or word on this? Thanks in advance.
It is possible to configure either behavior. If the password field in /etc/shadow begins with an exclamation point, then the account is locked. The account cannot be logged into with SSH and generally any attempt to access the account except by root will fail. If the password contains another invalid password (conventionally, on Linux, a single asterisk), then the account has no password (since the asterisk is not a valid encoding of any crypted password), but can be accessed by SSH public key authentication or other non-password means. If you use Debian or Ubuntu, you can configure these behaviors with adduser --disabled-login and adduser --disabled-password. The kernel is not involved in this; the decision is made by PAM and sshd.
Can a user with no password set login with ssh?
1,596,664,921,000
I have a gateway to ssh into from the bad world wide web. No problem, I get: remote ~$ ssh -X ingo@gateway Debian GNU/Linux 10 (buster) 0:ingo@gateway ~$ Now I manage my other hosts, for example the fileserver: 0:ingo@gateway ~$ ssh -X ingo@fileserver Warning: untrusted X11 forwarding setup failed: xauth key data not generated Debian GNU/Linux 10 (buster) 0:ingo@fileserver~$ I get that Warning. But if I ssh from my management host on the local network direct into the fileserver, it works without the Warning. I have verified this with other logins. I only get the Warning when ssh from a ssh. Why do I get Warning: untrusted X11 forwarding setup failed: xauth key data not generated only on nested ssh logins? How can I avoid this warning and can successful use the more secure untrusted X11 forwarding? And no, I do not want to use the less secure -Y option on ssh for trusted X11 forwarding instead of the used -X option.
When your only connection to an X11 server is untrusted, you cannot forward it further. The untrusted X11 forwarding works by the ssh client connecting to the local display, and using the xauth generate $DISPLAY . untrusted command to generate an untrusted key / cookie. But for that, the xauth command needs the SECURITY extension to be present on the display, which, like most extensions is hidden and/or disabled when a client like xauth was authenticated with an untrusted cookie. You can easily check that with: $ touch /tmp/junk1 /tmp/junk2 $ chmod 600 /tmp/junk* $ xauth -f /tmp/junk1 generate :0 . untrusted $ XAUTHORITY=/tmp/junk1 oclock # get a square oclock because the Shape extension is disabled $ XAUTHORITY=/tmp/junk1 xdpyinfo | grep -A2 extensions number of extensions: 2 BIG-REQUESTS XC-MISC # vs 28 or so on a trusted display $ XAUTHORITY=/tmp/junk1 xauth -f /tmp/junk2 generate :0 . untrusted xauth: (argv):1: couldn't query Security extension on display ":0" The latter step will cause the warning you get in ssh. So at least the first X11 forwarding should be trusted, otherwise it would not work. Alternatively, you should "jump" through the intermediate host, which will do a single X11 forwarding: ssh -X -o ForwardX11Trusted=no -J ingo@gateway ingo@fileserver Notice that explicit ForwardX11Trusted=no, because on Debian, the -X and -Y options are equivalent, and you'll get a trusted X11 forwarding by default no matter which one you're using.
"Warning: untrusted X11 forwarding setup failed" on nested ssh
1,596,664,921,000
I know there are a million similar posts, but I have not yet found one that answers this question. I'm trying to establish an ssh connection from an Ubuntu 18.04 client to the built-in OpenSSH SSH Server on the Windows-10 v1903 build. I do NOT have an Internet domain, so the Windows host will be visible on the Internet only using my ISP's assigned external IP address. To improve security, I want the Windows SSH server to REQUIRE BOTH public key authentication AND user password authentication. Additionally, I have configured the Windows server to use an alternate port for ssh. On the Windows host, while logged in as test_user, I used the command "ssh-keygen -t ecdsa" to create a user key-pair (with passphrase) and saved it to the file "test_user_key", from an Admin command prompt on Windows, used "ssh-add test_user_key" and confirmed using "ssh-add -l" to list the user even though C:\Users\test_user.ssh\authorized_keys appears to be empty and there is no \ProgramData\ssh\authorized_keys file at all! I then copied the resulting test_user_key private key to /home/xxx/.ssh on my Ubuntu client and set permissions to 600. With the Windows SSH server \ProgramData\ssh\sshd_config configured with "PubkeyAuthentication yes" and "PasswordAuthentication yes" but with "AuthenticationMethods" commented out, I tested the configuration LOCALLY, with the command "ssh -p 15001 -i test_user_key [email protected]" and, after entering the passphrase for the test_user key and the test_user account password, a connection is established and is confirmed with netstat. When I reconfigure the Windows sshd_config to enable "AuthenticationMethods publickey,password" then restart the Windows server service, and attempt the connection using "ssh -p 15001 [email protected]" from Linux to Windows, I am refused immediately (i.e. no prompt for the key's passphrase) with "[email protected]: Permission denied (publickey)." as expected because I failed to provide a key. I then provide the private key using the command "ssh -p 15001 -i test_user_key [email protected]" and am prompted to enter the key's passphrase, but receive the same "[email protected]: Permission denied (publickey)." after entering the passphrase. I believe the issue is that the actual test_user_key.pub key ends with "test_user@HOSTNAME" rather than [email protected]. But I cannot find a way to make ssh-keygen create a key-pair with the IP address rather than the HostName. Certainly, I'll eventually have to create a key-pair with my ISP's assigned external IP address. But ... (1) With AuthenticationMethods enabled in sshd_config I can't even get a connection established LOCALLY. (2) With AuthenticationMethos disabled, the Windows server allows a connection without a key file even when "PubkeyAuthentication" is enabled. (3) Why is Windows' authorized_keys empty? Help!
The publickey auth is failing because the authorized_keys file is empty. It is empty because you didn't add the public key to it. You could add it by first cd-ing to test_users .ssh directory on the windows box and running something like: cat id_ecdsa.pub >> authorized_keys (or whatever the public key's filename is, if it's not id_ecdsa.pub. Don't copy the private key to authorized_keys) BTW, if your ssh client machine already had a public & private key-pair, you could have just added that public key to the authorized_keys file. That's the more normal way of doing things - generate the key pair on the client, and install the public key (and only the public key) on the server. The server doesn't need to know (and in most cases, shouldn't) the client's private key. When you copied the key from the windows host to your client machine, did you copy the public key or the private key? Your ssh client machine needs the private machine in order to authenticate with the remote sshd server. You also need to make sure that your ~/.ssh/ directory perms are 700 AND the private key file perms are 600. Finally, the name (i.e. "test_user@HOSTNAME") at the end of the public key is irrelevant, it's just an arbitrary label.
How to Require PubkeyAuthentication using SSH from Linux client to Windows OpenSSH server
1,596,664,921,000
In ssh server and client authentication, key fingerprints are presented in different ways, even using the same command ssh-keygen -lf (in different hosts or as regards different keys). Representation 1: $ ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub 256 SHA256:3RE3UrGaTAec8H4YnZG7JTlfXpKvl89iexdqzLCyffY root@hostname1 (ED25519) Representation 2: $ ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub d0:21:3e:ec:52:ff:19:a9:e7:71:b5:7f:63:23:57:f7 (example from this page) Representation 3: AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHVo5+sYnRQxerJjG/DmUzQFso+CGzcnGT/SDa457qQqh6WIquvWOIXIY5gNPZoOByAoriK+WRxgTT39hYFmpXE= from $ ssh-keygen -H -F hostname2 |1|/DmY6Hm8TdZogykndJOUacp2NaM=|uM+t3vLw3KRySPUeXNqBLCxaGtY= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHVo5+sYnRQxerJjG/DmUzQFso+CGzcnGT/SDa457qQqh6WIquvWOIXIY5gNPZoOByAoriK+WRxgTT39hYFmpXE= which is the line in .ssh/known_hosts file corresponding to hostname2. What is the difference between them? And, if they are equivalent, how to get each representation from the other ones? Representations 1 and 3 have been obtained using OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017 on Ubuntu 18.04.
Older versions of the ssh-keygen utility from OpenSSH displayed only MD5 hashes; the utility now defaults to displaying a SHA256 hash, although you can still select an MD5 hash using the -E option: user@host:~/.ssh$ ssh-keygen -E md5 -l -f samplekey 2048 MD5:e6:1f:73:0f:14:cb:9a:71:2f:3b:31:b7:3f:58:1c:52 user@host (RSA) user@host:~/.ssh$ ssh-keygen -E sha256 -l -f samplekey 2048 SHA256:Oyt9H15ZBmITbhljpSiE/BLreo/+j+6lsC3gClGI97U user@host (RSA) user@host:~/.ssh$ ssh-keygen -B -l -f samplekey 2048 xomiz-lozad-ruzin-lasuz-vibic-fydar-hecoh-mapuv-vytus-futah-maxox user@host (RSA) In addition, you can add the -v (visual) flag on either the MD5 or SHA256 hash to get an ascii-art comparison image in addition to an alphanumeric hash: user@host:~/.ssh$ ssh-keygen -E sha256 -l -v -f samplekey 2048 SHA256:Oyt9H15ZBmITbhljpSiE/BLreo/+j+6lsC3gClGI97U user@host (RSA) +---[RSA 2048]----+ | . .. =.. | |.. +. + * | |o o .+. . O . | | o . .o... o o . | |. ..E.S o| | . . . . + | |. . o..o . . o | | . o +=.*.. o | | .. o+BXo..o | +----[SHA256]-----+ user@host:~/.ssh$ Your third representation is not a fingerprint, but the public key, base-64 encoded, as it will be stored in a samplekey.pub file or in the known_hosts file on a system accepting that key. There is no way to determine the key from the hash; to obtain the hash from the key, use the ssh-keygen utility either with its default options, or using the -E, -B, and/or -v options to get the output style you prefer. To obtain the fingerprint of a key in a known_hosts file (rather than in the original public key file, as per examples above), you could pipe a string containing the key-type and the key directly to ssh-keygen: $ echo "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHVo5+sYnRQxerJjG/DmUzQFso+CGzcnGT/SDa457qQqh6WIquvWOIXIY5gNPZoOByAoriK+WRxgTT39hYFmpXE=" | ssh-keygen -l -f - 256 SHA256:wOxOBgRQp1qQcnTIjgmE/GB8+3fm8ahyDXuL/2GzgIo no comment (ECDSA)
Several representations for key fingerprint
1,596,664,921,000
I must update OpenSSH on my RHEL 5.5 because of CVE-2018-15473. My OpenSSH version is OpenSSH_4.3p2 and must be update to OpenSSH_7.9, when i want to do this i get that message when using configure command checking OpenSSL library version... configure: error: OpenSSL >= 1.0.1 required (have "0090802f (OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008)") so i download OpenSSL_1.0.1a and try to install it, when i use make test command after ./config and make i get that error at the end error make[1]: ** [test_cms] Error 1 make[1]: Leaving directory `/u01/install/openssl-1.0.1p/test' make: ** [tests] Error 2*** So... How can i update my OpenSSL and then update OpenSSH??? I cant connect my linux os to internet
I solved my problem with the below string of commands: Download the latest version of the OpenSSL source package: wget ftp://ftp.openssl.org/source/openssl-1.0.1g.tar.gz Install OpenSSL 2 & openssh-7.9p1: tar xzvf openssl-1.0.1g.tar.gz tar -zxvf openssh-7.9p1.tar.gz cd openssl-1.0.2p ./config shared zlib make install mv /usr/bin/openssl /usr/bin/openssl.OFF mv /usr/include/openssl /usr/include/openssl.OFF ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl ln -s /usr/local/ssl/include/openssl /usr/include/openssl echo "/usr/local/ssl/lib" >> /etc/ld.so.conf ldconfig -v openssl version cd openssh-7.9p1 /configure --with-ssl-dir=/usr/local/ssl/bin/openssl make make install sshd -version
Update OpenSSH on RHEL 5.5
1,596,664,921,000
Suppose these two operating systems and SSH software: GNU/Linux Debian 9.3 with OpenSSH version 1:7.4p1-10+deb9u2 Linux Mint 18.3 with OpenSSH version 1:7.2p2-4ubuntu2.4 And I want to switch away from rsa completely to the benefits of curve ed25519. The question is, after I generate ed25519 on both systems with: ssh-keygen -t ed25519 And copy the public keys with ssh-copy-id, shall I delete the rsa key-pair with rm or is that a wrong way?
No, deleting the key pair is fine. All you have to do is to delete your public key from the server. However, you don't remove it with rm; you delete the relevant lines from the ~/.ssh/authorized_keys file. Check first that you can log in with your new key pair! For cleanliness, I'd also suggest you to remove your private key from the client machine, although that would make no difference.
What is the correct way to remove RSA key-pair entirely from my SSH configuration?
1,596,664,921,000
So I've been trying for the past two hours to SSH into my own computer via localhost. But it says "Permission Denied (public key)". I am running Ubuntu 14 LTS on VirtualBox. Here're my current settings: My /home/username directory has the ".ssh" folder with the files "known_hosts", "initialkey" and "initialkey.pub". I generated the initialkey files with RSA. My "/etc/ssh" folder also has two RSA files - "ssh_host_rsa_key" and "ssh_host_rsa_key.pub" (these RSA keys are different from the ones in /home/username/.ssh folder). The "sshd_config" file has disabled password authentication, disabled root login and both public key and RSA authentication are enabled. The value of "AuthorizedKeysFile" is set to "/root/.ssh/authorized_keys". In "/root/.ssh/authorized_keys", I've copied the above mentioned "initialkey.pub" file. I've checked the permissions to make them all at least "r" for all users. Still, the problem persists. Maybe my concept of how SSH into my local machine works is incorrect. As of now, I believe that "openssh server" is making my machine into a server, and by using ssh localhost command, I can log into that server even from the same machine. UPDATE: The problem has been solved by changing the permission of the home directory. I used the command chmod 750 $HOME, which solved the issue. Thank you all for your inputs.
SSH is very paranoid about keys. If any directory on the path is writable by anyone other than the owner it will not trust the key. Check the permissions on all the directories in the path. Permissions should be something like drwxr-xr-x or drwxr-x---. Permissions like drwxrwxr-x or drwxrwxrwx will cause the key to be untrusted.
Can't SSH into localhost
1,596,664,921,000
I'm trying to SSH from Debian (Jessie, installed as chroot environment in Chrome OS) to Arch on the same network, and I keep getting an error saying the connection was refused because of a public key error.
Option 1 Enable password authentication on Server (your computer running arch-linux) Edit the SSH configuration file on the server to allow password authentication. [user@arch]$ sudo nano /etc/ssh/sshd_config PasswordAuthentication yes ChallengeResponseAuthentication yes Use your favorite text editor instead of nano, such as vim. To use vim, once it opens the file, hit i to switch to insert mode make your edits then press esc to leave insert mode and type :wq and hit enter to write changes and quit. Note: sudo is not part of the initial installation of arch-linux. As an alternative login to root with su. Now if key authentication fails you will be prompted to enter your password for the user account on the arch computer. Option 2 Generate key and send to Server [you@debian]$ ssh-keygen [you@debian]$ ssh-copy-id user@arch-hostname
SSH public key error
1,596,664,921,000
I have the following setup: Computer A has a Wifi-USB adapter (and is a robot, so it doesn't need real internet access). It's running Ubuntu 14.04. Computer B is my Laptop running Ubuntu 14.04 also. What I have done is setup a local Wifi hotspot on Computer B using this guide. It has an ethernet cable connected to it, which gives it access to the "outside". It works fine, computer A can join the network and I can ping computer A from Computer B and the other way around. However, I cannot ssh from Computer B to Computer A, I always get the following error. ssh [email protected] ssh: connect to host ComputerA.local port 22: Connection refused To my understanding I do not need to install openssh-server on Computer A, since I am only trying to ssh while in the same network. (Is this correct?) If I run sudo iptables -L I get the follwong output: Computer B: Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT udp -- anywhere anywhere udp dpt:bootps ACCEPT tcp -- anywhere anywhere tcp dpt:bootps ACCEPT udp -- anywhere anywhere udp dpt:domain ACCEPT tcp -- anywhere anywhere tcp dpt:domain Chain FORWARD (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere 10.42.0.0/24 state RELATED,ESTABLISHED ACCEPT all -- 10.42.0.0/24 anywhere ACCEPT all -- anywhere anywhere REJECT all -- anywhere anywhere reject-with icmp-port-unreachable REJECT all -- anywhere anywhere reject-with icmp-port-unreachable Chain OUTPUT (policy ACCEPT) target prot opt source destination Computer A: Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination I have ufw disabled on both computers. Since I am really not a ssh expert, can anybody tell me what I can do to fix this? If further information is needed, I'd be glad to provide it.
Ok, apparently I do need openssh-server on Computer A, even though I am in the same network. I read that wrong somewhere else then.
SSH in local network while hosting same network
1,596,664,921,000
When ssh'ing to my server (RaspPi running Arch), it doesn't accept my password (which I'm 98% sure is correct), and the usual delay before Permission denied, please try again. is not there. Elsewise, the server is running fine. I tried using the default /etc/ssh/ssh_config and /etc/ssh/sshd_config to no avail. Login with root is the same, no delay before asking the password again. I don't have any monitor to connect to the Pi, so can't check journalctl and similar, but I have physical access to the sd card. As mentioned, I've set ssh_config and sshd_config to default, and am utterly confused as to why openssh is behaving like this. Here's ssh -v to root with ip retracted (don't see anything unusual myself): OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to ****.com [**.***.***.**] port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/****/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.1 debug1: match: OpenSSH_7.1 pat OpenSSH* compat 0x04000000 debug1: Authenticating to *********.com:22 as 'root' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client [email protected] <implicit> none debug1: kex: client->server [email protected] <implicit> none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:TPjpBFxCBTcJR+zUv0KRTd3ImVCWzAk8D2U++W422oA debug1: Host '******.com' is known and matches the ECDSA host key. debug1: Found key in /home/****/.ssh/known_hosts:3 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Trying private key: /home/****/.ssh/id_rsa debug1: Trying private key: /home/****/.ssh/id_dsa debug1: Trying private key: /home/****/.ssh/id_ecdsa debug1: Trying private key: /home/****/.ssh/id_ed25519 debug1: Next authentication method: password root@*******.com's password: debug1: Authentications that can continue: publickey,password Permission denied, please try again. root@******.com's password: debug1: Authentications that can continue: publickey,password Permission denied, please try again. root@******com's password:
Thanks to @ams, I got access to the logs, where it seemeed to be a problem with PAM. I disabled pam-authentication in sshd_config, and was able to log in as root. There I could do a system update (in which pam had a new version), and logging in as my normal user is now possible. However, for some reason the pause between login attempts over ssh is still not there (which obviously is a seriuos security problem), but I'll post a separate question about this if need be.
SSH login not accepted, and no delay between ssh login attempts
1,596,664,921,000
I have a reverse SSH server in Cisco router(runs IOS operating system) and it listens on port 2001: C1841#sh control-plane host open-ports Active internet connections (servers and established) Prot Local Address Foreign Address Service State tcp *:22 *:0 SSH-Server LISTEN tcp *:23 *:0 Telnet LISTEN tcp *:2001 *:0 SSH-Server LISTEN C1841# In other words, if I connect to port 2001(ssh 10.10.10.2 -l root -p 2001), then I'm able to access RS-232 console port of another device which is connected to AUX port of the router. However, instead of ssh 10.10.10.2 -l root -p 2001 I can simply execute ssh root:[email protected]. This feature is also described in this blog post. Am I correct that this is not a feature of OpenSSH client, but instead Cisco IOS parses the username in a way that integer after colon is taken as a line number(line number 1 us usually AUX port in IOS)?
This is simply a feature of the Cisso ssh server implementation; it parses the user name, and if it contains a :[0-9]+ component then it understands it has to connect the session to the console port with the corresponding number. Note it has nothing to do with an alternate port number, those connects happen over port 22.
Integer after username in OpenSSH client separated by colon
1,596,664,921,000
I have downloaded and compiled the latest version of libssl, the result of which is located at /usr/local/ssl. I want to compile libssh2 using the files in this folder, and to do that I've set the switch --with-libssl-prefix=/usr/local/ssl. After performing ./configure --with-libssl-prefix=/usr/local/ssl and make, the resulting libssh2.so, according to the output of ldd, depends on the libssl found in the /usr/lib64, which is exactly what I don't want. What can I do to force libssh2 to be compiled with the libssl I have in /usr/local/ssl?
If you compiled and installed libssl into the default /usr/local path, there is a /usr/local/ssl, but the lib is not in there; it's just directories like certs and misc -- stuff that other things would probably put in a share directory (e.g. /usr/local/share/ssl). The actual library is installed in a normal place, /usr/local/lib. Presuming you've already run ldconfig and that path is in a file in /etc/ld.so.conf.d, you should be able to then do: ldconfig -p | grep ssl And all the => paths should be into /usr/local/lib. If so, you can use: --with-libssl-prefix=/usr/local/ No ssl or lib, etc. It should now be found properly.
Compiling LibSSH2 with specific LibSSL
1,596,664,921,000
All of a sudden, I couldn't ssh to a machine to which I used to ssh earlier. Consider I am ssh-ing from A to B. Output when I run ssh root@ip_addr_of_B I get: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Output when I run ssh -vv root@ip_addr_of_B from A OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to 64.103.232.105 [64.103.232.105] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/identity type -1 debug2: key_type_from_name: unknown key type '-----BEGIN' debug2: key_type_from_name: unknown key type '-----END' debug1: identity file /root/.ssh/id_rsa type 1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug2: fd 3 setting O_NONBLOCK debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_setup: found hmac-md5 debug1: kex: server->client aes128-ctr hmac-md5 none debug2: mac_setup: found hmac-md5 debug1: kex: client->server aes128-ctr hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug2: dh_gen_key: priv key bits set: 124/256 debug2: bits set: 523/1024 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host '64.103.232.105' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts:3 debug2: bits set: 522/1024 debug1: ssh_rsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /root/.ssh/identity ((nil)) debug2: key: /root/.ssh/id_rsa (0x7f972bb77030) debug2: key: /root/.ssh/id_dsa ((nil)) debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug2: we did not send a packet, disable method debug1: Next authentication method: gssapi-with-mic debug1: An invalid name was supplied Cannot determine realm for numeric host address debug1: An invalid name was supplied Cannot determine realm for numeric host address debug1: An invalid name was supplied debug1: An invalid name was supplied debug2: we did not send a packet, disable method debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/identity debug1: Offering public key: /root/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: Trying private key: /root/.ssh/id_dsa debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Below is the sshd_config file of B. # $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/local/bin:/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 change a # default value. Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: # Disable legacy (protocol version 1) support in the server for new # installations. In future the default will change to require explicit # activation of protocol 1 Protocol 2 # HostKey for protocol version 1 #HostKey /etc/ssh/ssh_host_key # HostKeys for protocol version 2 #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_dsa_key # Lifetime and size of ephemeral version 1 server key #KeyRegenerationInterval 1h #ServerKeyBits 1024 # Logging # obsoletes QuietMode and FascistLogging #SyslogFacility AUTH SyslogFacility AUTHPRIV #LogLevel INFO # Authentication: #LoginGraceTime 2m #PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #RSAAuthentication yes #PubkeyAuthentication yes #AuthorizedKeysFile .ssh/authorized_keys #AuthorizedKeysCommand none #AuthorizedKeysCommandRunAs nobody # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts #RhostsRSAAuthentication no # similar for protocol version 2 #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # RhostsRSAAuthentication and 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 yes #PermitEmptyPasswords no PasswordAuthentication no # Change to no to disable s/key passwords #ChallengeResponseAuthentication yes ChallengeResponseAuthentication no # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no #KerberosUseKuserok yes # GSSAPI options #GSSAPIAuthentication no GSSAPIAuthentication yes #GSSAPICleanupCredentials yes GSSAPICleanupCredentials yes #GSSAPIStrictAcceptorCheck yes #GSSAPIKeyExchange no # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication 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 ChallengeResponseAuthentication to 'no'. #UsePAM no UsePAM yes # Accept locale-related environment variables AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE AcceptEnv XMODIFIERS #AllowAgentForwarding yes #AllowTcpForwarding yes #GatewayPorts no #X11Forwarding no X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes #PrintMotd yes #PrintLastLog yes #TCPKeepAlive yes #UseLogin no #UsePrivilegeSeparation yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #ShowPatchLevel no #UseDNS yes #PidFile /var/run/sshd.pid #MaxStartups 10 #PermitTunnel no #ChrootDirectory none # no default banner path #Banner none # override default of no subsystems Subsystem sftp /usr/libexec/openssh/sftp-server # Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # ForceCommand cvs server /var/log/secure of B contains just this one line server sshd: connection closed by ip_addr_of_A I can ssh from B to A. Issue happens only when I ssh from A to B. Also, I can ssh from A to any machine other than B.
Obviously you disabled password authentication, you don't have ssh keys and kerberos is not configured. Either login locally or login via serial console, or via KVM or if you have server-class machine then it should have a management interface (BMC) allowing remote access to local serial port or making graphical console redirection. Out of that, you are out of luck.
Can't ssh to a machine
1,596,664,921,000
I am trying to use ssh to connect to a server on 3 different thinkpads: T430s, E420, and a T400. SSH just hangs at connecting to sdf.org [205.166.94.16] port 2 (sdf is a known working ssh server). I can telnet, ping, curl, and even telnet over port 22 sdf.org with no issues. I can also connect using my desktop which is on the same network. Here's the log when I run ssh -vvv [email protected]: I have tried connecting through different interfaces (WiFi as opposed to Ethernet). I also tried my phones hotspot and that did work, however I checked my routers configuration extensively and I checked with my ISP (Xfinity) to see if they were blocking any traffic. Output of ip route show: Output of cat /etc/resolv.conf: Pinging, curling, telneting, and telneting over port 22 on sdf.org:
According to this, some routers dislike the IP_TOS value set by ssh. You may check if that is the case by running: ssh -o "IPQoS 0x00" -vvv [email protected] If that works, you can avoid typing it all the time by adding that option (without the quotes, just IPQoS 0x00) to the relevant portion of your ssh config file (e.g. $HOME/.ssh/config or /etc/ssh/ssh_config). As a curiosity, in your system the IP_TOS (yes, the kernel code calls it IP_TOS, while the OpenSSH option is IPQoS) is set to 0x48 (IPTOS_PREC_IMMEDIATE + IPTOS_THROUGHPUT)—either in a config file or that is the default in your openssh package—while in mine (Ubuntu 22.04 with OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022) the default is just 0x10 (IPTOS_LOWDELAY). If you want to experiment with other values, you can find them here.
Unable to connect to anything using ssh
1,596,664,921,000
About the ssh-keyscan command for the -H option according with: ssh-keyscan — gather ssh public keys it indicates -H Hash all hostnames and addresses in the output. Hashed names may be used normally by ssh and sshd, but they do not reveal identifying information should the file's contents be disclosed. I don't understand neither the idea nor its purpose. It is the reason of this post. Please Can you clarity its use? I did realize for two different hosts, that if is executed # Pair I ssh-keyscan 192.168.1.x ssh-keyscan 192.168.1.y # Pair II ssh-keyscan -H 192.168.1.x ssh-keyscan -H 192.168.1.y The first pair: for each IP, the output for each public key appears and indicating the key type as dsa, ecdsa, ed25519 and rsa. The second pair: for each IP, the output for each public key appears, and indicating the key type as dsa, ecdsa, ed25519 and rsa - however appears at the beginning for each key type the |1| text with some random text Question: How does -H work in the ssh-keyscan command? Extra Questions When is mandatory use -H? What does |1| with some random text mean? Remember, |1| with some random text appears in the output for two different hosts, it for each key type. So I am assuming it is not a coincidence Note I am not sharing the outputs just for security reasons
The one-way hashing is advertised as a means to make it more difficult for an attacker to know what hosts you SSH to should said attacker get their hands on your known_hosts file. Here is what ssh_config(5) says: HashKnownHosts Indicates that ssh(1) should hash host names and addresses when they are added to ~/.ssh/known_hosts. These hashed names may be used normally by ssh(1) and sshd(8), but they do not visually re- veal identifying information if the file's contents are dis- closed. The default is no. This is security through obscurity, though leans towards "good obscurity" as it may make it more difficult for an attacker to find additional hosts to target, or for someone to know that you have been connecting to an politically inapropriate system. There are other ways to find this information (firewall logs, network flow records, DNS, etc), but an easily read unhashed text file is great for an attacker, and the other means may not be available or may take too long. (You should probably also encrypt the disk for better "defense in depth", though that will not help if an application exploit allows direct access to the mounted filesystem, or if they find your screen unlocked, etc.)
How does -H work in the ssh-keyscan command?
1,596,664,921,000
In sshd(8) man page: The OpenSSH SSH daemon supports SSH protocol 2 only. Each host has a host-specific key, used to identify the host. Whenever a client connects, the daemon responds with its public host key. The client compares the host key against its own database to verify that it has not changed. Forward secrecy is provided through a Diffie-Hellman key agreement. This key agreement results in a shared session key. The rest of the session is encrypted using a symmetric cipher. (Emphasized by me) Can someone explain to me how does the authentication process work? As I understand: Each host will have a unique ssh key (public and private) When a client connects to a server, the sshd daemon provides the client with a public key The client then do something that I don't understand After that, the rest of that session is encrypted. Am I correct? Can someone explain in detail what does The client compares the host key against its own database to verify that it has not changed means?
Can someone explain in detail what does The client compares the host key against its own database to verify that it has not changed means? When you ssh into a (previously unknown) machine, you will get this query (for e.g. ECDSA-type key): ssh user@newhost: The authenticity of host 'newhost (<IP-address>)' can't be established. ECDSA key fingerprint is SHA256:<fingerprint>. Are you sure you want to continue connecting (yes/no/[fingerprint])? When answering with yes: Warning: Permanently added 'newhost,<fingerpint>' (ECDSA) to the list of known hosts. The host fingerprint is now added to the file ~/.ssh/known_hosts(default location). For future connections, the host can be uniquely identified with this fingerprint and the dialogue thus does not appear. If, however, the host fails to do so, you will receive a warning about a change in the host. This is to ensure that no one may just capture the host, redirect the domain, etc, without you as ssh-client receiving a warning about this. Compare it to a website certificate that you manually accept once and if it changes the website is marked insecure.
How does the sshd authentication process work?
1,596,664,921,000
In OpenSSH, verbose mode (ssh -v ...) shows some useful statistics on exit (e.g. Transferred: sent 3532, received 3076 bytes, in 5.5 seconds). However, verbose mode also prints lots of debug1: ... lines that I do not care about. For example: $ ssh -v -N -D localhost:12345 [email protected] OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020 debug1: Reading configuration data /home/user/.ssh/config debug1: /home/user/.ssh/config line 5: Applying options for * debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * --- snip --- debug1: channel 0: free: port listener, nchannels 4 debug1: channel 1: free: port listener, nchannels 3 debug1: channel 2: free: port listener, nchannels 2 debug1: channel 3: free: port listener, nchannels 1 Transferred: sent 3532, received 3076 bytes, in 5.5 seconds Bytes per second: sent 638.4, received 556.0 debug1: Exit status 0 How do I remove all the debug1: ... lines to show the data usage statistics only? I only want to see the Transferred: ... and Bytes per second: ... lines. I tried ssh -v ... 2>&1 | sed '/debug1/d', but that does not work because Ctrlc produces a SIGINT that is sent to all processes in the foreground process group. sed is terminated before the usage statistics get sent to its standard input, so the usage statistics are never printed. I am using /bin/sh (not bash) as my shell.
The "transferred..." messages are printed at the "verbose" log level. You can set ssh to the "verbose" level using the "-o LogLevel" option: % ssh -o LogLevel=verbose localhost echo hello Authenticated to localhost ([::1]:22). hello Transferred: sent 2768, received 2880 bytes, in 0.0 seconds Bytes per second: sent 117942.8, received 122715.1 % You can set this in your .ssh/config file if you want it to happen automatically: Host example.com LogLevel verbose
SSH verbose mode: how to view amount of data transferred without all the "debug1" lines?
1,596,664,921,000
How to convert RFC4716 private keys to PEM private keys in ubuntu 20.04? For our project we generated ssh keys on a device running the latest openssh software. JSch complained about authentication: Exception com.jcraft.jsch.JSchException: Auth fail After a lot of research, including building a minimal git client we discovered a small change to our other key files. The header didn’t start with ​—–BEGIN RSA PRIVATE KEY—– but it started with —–BEGIN OPENSSH PRIVATE KEY—– showing, that this key is formatted in the new default RFC4716 format. I have same question here, but I want to use my original key instead of regenerate one. And I don't want to use GUI applications like PuTTY. I want convert it in scripts. I tried several attempts, non of these works: ssh-keygen -f id_rsa -m 'PEM' -e ssh-keygen -f id_rsa -e -m pem # I got PUBLIC KEY instead of private key openssl rsa -in ~/.ssh/id_rsa -outform pem openssl rsa -in id_rsa -pubout -out id_rsa.pub.pem openssl rsa -in ~/.ssh/id_rsaunable to load Private Key # unable to load Private Key # 139920849113728:error:0909006C:PEM routines:get_name:no start line:../crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY How do I convert it?
$ cat /tmp/test -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn NhAAAAAwEAAQAAAYEArKk9jKvP/kwZq5GAog449OK5LzjppL5DbQhlJcqntzqu88+6WDHr lQM0IKyHgEkRDim8MrmisK2eIJrmj99STJEBPu7jgJ0q2ASToSeFiU8FB+yrV9ZmelwJ7f 1rD5vp3TlROAc08pIKb2YVHE4KfLzAncGXVETldTuGDAHgXQWIlhZDBGbkt8pwM/Kt10j4 t7snCGKNWm8c9K943Tv3J+okI+vdv3V5a2dfoCW+9cnNE57jotE/LTli5CwuxFcX5zc1ON i/l0opxWAfhi4sCZBiaMnMfSX9kvYNl0cnaIRvzB3/CoSkxq9OJicQ2dDtXVu1LUvUrtHl abfthPq2UttHzwZWEVxR5ZYfW3v7hXgc5MrOMabffAu9ALs7eDv+3gnVNbp1Qv5Jl9L+R9 VXO7OVxmWhPGrLlVZJr078rNfZBLt4UEkiM9kswF0w+IVdUYm/VBJBSgfqCSo1xXxy9u8z zywqTn6/MW0zInF5nxcfBb8zomZUEmJeoZnWlGN9AAAFgDrUKVw61ClcAAAAB3NzaC1yc2 EAAAGBAKypPYyrz/5MGauRgKIOOPTiuS846aS+Q20IZSXKp7c6rvPPulgx65UDNCCsh4BJ EQ4pvDK5orCtniCa5o/fUkyRAT7u44CdKtgEk6EnhYlPBQfsq1fWZnpcCe39aw+b6d05UT gHNPKSCm9mFRxOCny8wJ3Bl1RE5XU7hgwB4F0FiJYWQwRm5LfKcDPyrddI+Le7JwhijVpv HPSveN079yfqJCPr3b91eWtnX6AlvvXJzROe46LRPy05YuQsLsRXF+c3NTjYv5dKKcVgH4 YuLAmQYmjJzH0l/ZL2DZdHJ2iEb8wd/wqEpMavTiYnENnQ7V1btS1L1K7R5Wm37YT6tlLb R88GVhFcUeWWH1t7+4V4HOTKzjGm33wLvQC7O3g7/t4J1TW6dUL+SZfS/kfVVzuzlcZloT xqy5VWSa9O/KzX2QS7eFBJIjPZLMBdMPiFXVGJv1QSQUoH6gkqNcV8cvbvM88sKk5+vzFt MyJxeZ8XHwW/M6JmVBJiXqGZ1pRjfQAAAAMBAAEAAAGBAKRYr3JvtBo8+444gDVAzmwiRt yxEowyYmGtRQH05TFeVVtTle8PDUuYcgzLzGqKogZWKYIq+rWrfMFSUDYP/vlMaOAraTdp 4ncd3BvgT5ZENei2GN4SARdk9jqnJjoEUVW2kh1/lqFx6ybgByYbDpZu3/UJaW7X6YVuNA jH3HUOqFUcOYw+GGTs92IrE9fA6KWSKfQsQpoa+3fYcnY69uXyU5Yxk7ADNKDME9SPOTYh cOfFLK40+Cqm3f+MIrPWpSRO0Dcselcq/YpxdjmcaXVnVj/XqTGQwCn8akCtgjarcaOkw5 zO/UN1aphzCgojhH0HzV67ufG2alO1BYz5Hd1dyPX8itdDOUcT6x1FRoiFkmvkbTVXl3FM JynzmPzuHRnmHrolhNy8ZeaE63I27TDDausddWQ7Pn03LFazwJKYvCoxWBlT+8bMmiY2AC C5iNiMgxqudh90CLoyPg3eyIJ8La2l/I+CcZuQsFG4dx9QaFQxJUQCLtW0CNWATflRzQAA AMAV8M+lLQUOBGs0S4bVnqTvRmERY81YRyhB+sOYGMdY/6jW+BvFqDCP/y1wTmPgFA/tUI oAvc2LkX47lEHsV/pJa7Dk0FK6rNRL3puu2M+bWFcHAIxizHNzTcYPlTz89d9TVg1TvvmR r5DCNAvGAD+b1947YqNH+Dt3yw5XzYu3EacU4lyeYpaAoeB1P3+eJv5Y06isQO7r1S9DWI wr24nyKxE1Ur1kh+lbSm7+cJgf4s8sJi/d5PB4dagjGfa/dOgAAADBANxHZ+NQnsyAEqBX gGC/5VCDbvzFBZWvYGkRn3TJkIDIZvN142MYDkbG5JDxm7k/JJ0Cbqx1GY5S4BZ1ogju/g u8qIz/lMIwpmLAd09n14xVXOVLKnN9GpQ0505+CDaNIK2ANcMqB4auovJcVNTkIVrxVjs4 vEEyVjI5ze+jBNqJstEuk6IaSEzcMckXSdMDcfnPh7b2QanL6KkCUhxaK1ftG/K+4znEtx pHYbDy7uEwx4whDhyZn0EAQZ+NZ8leHwAAAMEAyKkKv2treH+WPO0S+d7KTNJRJv4tiiOE VBTL+evXzVxXLwQDCoQ4sV0+Ye7j9D75kGDIoxnkJZiCab8WMDeFP78awDVYru7My739K/ v2LwS0yeMSDNitvoDN+wu5kn2oskMoZRDTG2EHKxreMdu6vHEPRsmx6zmx53ogRFsa+jnV DHrfSx7nQL28lrWvcDkQ6apvdjLj8i/ZYP9KC9f2VfYpqgI/1ONDG3ndXgn8cFkLdSnF2Y 1yWVGKN2wVIFLjAAAACWppcmlAdDUwMAE= -----END OPENSSH PRIVATE KEY----- $ ssh-keygen -p -f /tmp/test -m PEM Key has comment 'jiri@t500' Enter new passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved with the new passphrase. $ cat /tmp/test -----BEGIN RSA PRIVATE KEY----- MIIG5QIBAAKCAYEArKk9jKvP/kwZq5GAog449OK5LzjppL5DbQhlJcqntzqu88+6 WDHrlQM0IKyHgEkRDim8MrmisK2eIJrmj99STJEBPu7jgJ0q2ASToSeFiU8FB+yr V9ZmelwJ7f1rD5vp3TlROAc08pIKb2YVHE4KfLzAncGXVETldTuGDAHgXQWIlhZD BGbkt8pwM/Kt10j4t7snCGKNWm8c9K943Tv3J+okI+vdv3V5a2dfoCW+9cnNE57j otE/LTli5CwuxFcX5zc1ONi/l0opxWAfhi4sCZBiaMnMfSX9kvYNl0cnaIRvzB3/ CoSkxq9OJicQ2dDtXVu1LUvUrtHlabfthPq2UttHzwZWEVxR5ZYfW3v7hXgc5MrO MabffAu9ALs7eDv+3gnVNbp1Qv5Jl9L+R9VXO7OVxmWhPGrLlVZJr078rNfZBLt4 UEkiM9kswF0w+IVdUYm/VBJBSgfqCSo1xXxy9u8zzywqTn6/MW0zInF5nxcfBb8z omZUEmJeoZnWlGN9AgMBAAECggGBAKRYr3JvtBo8+444gDVAzmwiRtyxEowyYmGt RQH05TFeVVtTle8PDUuYcgzLzGqKogZWKYIq+rWrfMFSUDYP/vlMaOAraTdp4ncd 3BvgT5ZENei2GN4SARdk9jqnJjoEUVW2kh1/lqFx6ybgByYbDpZu3/UJaW7X6YVu NAjH3HUOqFUcOYw+GGTs92IrE9fA6KWSKfQsQpoa+3fYcnY69uXyU5Yxk7ADNKDM E9SPOTYhcOfFLK40+Cqm3f+MIrPWpSRO0Dcselcq/YpxdjmcaXVnVj/XqTGQwCn8 akCtgjarcaOkw5zO/UN1aphzCgojhH0HzV67ufG2alO1BYz5Hd1dyPX8itdDOUcT 6x1FRoiFkmvkbTVXl3FMJynzmPzuHRnmHrolhNy8ZeaE63I27TDDausddWQ7Pn03 LFazwJKYvCoxWBlT+8bMmiY2ACC5iNiMgxqudh90CLoyPg3eyIJ8La2l/I+CcZuQ sFG4dx9QaFQxJUQCLtW0CNWATflRzQKBwQDcR2fjUJ7MgBKgV4Bgv+VQg278xQWV r2BpEZ90yZCAyGbzdeNjGA5GxuSQ8Zu5PySdAm6sdRmOUuAWdaII7v4LvKiM/5TC MKZiwHdPZ9eMVVzlSypzfRqUNOdOfgg2jSCtgDXDKgeGrqLyXFTU5CFa8VY7OLxB MlYyOc3vowTaibLRLpOiGkhM3DHJF0nTA3H5z4e29kGpy+ipAlIcWitX7RvyvuM5 xLcaR2Gw8u7hMMeMIQ4cmZ9BAEGfjWfJXh8CgcEAyKkKv2treH+WPO0S+d7KTNJR Jv4tiiOEVBTL+evXzVxXLwQDCoQ4sV0+Ye7j9D75kGDIoxnkJZiCab8WMDeFP78a wDVYru7My739K/v2LwS0yeMSDNitvoDN+wu5kn2oskMoZRDTG2EHKxreMdu6vHEP Rsmx6zmx53ogRFsa+jnVDHrfSx7nQL28lrWvcDkQ6apvdjLj8i/ZYP9KC9f2VfYp qgI/1ONDG3ndXgn8cFkLdSnF2Y1yWVGKN2wVIFLjAoHBAKz7/l+Kzkn2QapdTNmt mN2TebNS3cHgyat5RWmnaK1Zs095wqntGDkItDIHKq1dItmSMWuJQhp8hrHcivTN CgAZlZu0khO1tNRUJN3cxG7WEm+Wia3MDvVYXlVLsBN23LSjvJSZCvP/bMM7MvtE c9VBNOCo+12PtBUZQ9nugT9FZ4HSO+nPDfwd55LtkPH/AKCXExLhbEt1cC5ZPjY5 sVQJRitpMHQLQWeHqvYUsPdzISGwS662DVQ0aVRs7ZY7LQKBwQCOrRuWRgQRlu61 fYB7qL1BaF4JkrvAuEZUHsF2gApe2+Sl6n1bEe7ZtkowClONjOWYkii3SCaf0NQR 6qwVNrUJQZH8zzGymNuHlxyYFLzUa808q7de6QaJKT7M3WZi0fSMZBIp4o+orRIS xTTuUKVzbhSFqc5XShvEUmL1F66T82EYUZnJ6TxXHVIl+yO2cO0kqGo+qirIPtub C4qT50ghkTnIx3apobpKpBkRz5nuLHJoKX6jlN6UwdS8WZ6f8C8CgcAV8M+lLQUO BGs0S4bVnqTvRmERY81YRyhB+sOYGMdY/6jW+BvFqDCP/y1wTmPgFA/tUIoAvc2L kX47lEHsV/pJa7Dk0FK6rNRL3puu2M+bWFcHAIxizHNzTcYPlTz89d9TVg1TvvmR r5DCNAvGAD+b1947YqNH+Dt3yw5XzYu3EacU4lyeYpaAoeB1P3+eJv5Y06isQO7r 1S9DWIwr24nyKxE1Ur1kh+lbSm7+cJgf4s8sJi/d5PB4dagjGfa/dOg= -----END RSA PRIVATE KEY-----
How to convert RFC4716 private keys to PEM private keys?
1,561,648,719,000
My question regards ssh, sftp, scp, rsync, etc. commands where you connect to another machine which can be in your Local Area Network (LAN) or at some remote location you would typically connect via the Wide Area Network (WAN) or greater internet. For instance, if you were to use these each of these two commands, ssh [email protected] ssh [email protected] whereby you connect namely to a remote machine or a LAN machine respectively, does the actual connection path change if you are in the same LAN? Note publicIP.com represents the IP address or domain name that applies to both the host and the machine executing this command. As an example, consider the case you are at home and have two machines connected to the internet through the same router. I would expect the second command to send data from machine1-->router-->machine2. Does the first command do the same or does it do machine1-->router-->some remote path-->router-->machine2? And in the second case, will this contribute to the bandwidth your ISP monitors and caps?
First your router is not just a router, it is also a ethernet switch, a DHCP server, A wifi hotspot, a modem, … 2nd it should be routed the best way: if on same sub-net 192.168.0.x then it will be routed by the machines, and not go through the router (not the router part of the router, just the ethernet switch). What happens when you use a domain name e.g. publicIP.com First the name is looked up: this may be done using /etc/hosts, bonjour/avahi, DNS, or other resolver. (This step may involve asking a public DNS server, so some public traffic. But it is cached for several minutes.) Then an attempt it made to connect to the ip address. e.g. If we do ssh [email protected] and the DNS A record of publicIP.com is 192.168.0.100, then the DNS look up returns 192.168.0.100. Then ssh does the connection ssh [email protected], and therefore routed the same as if you specified 192.168.0.100. A note on http In http the original name is also passed to the server (after the connection is made), this is sometimes use to distinguish which virtual server to connect to (at the same IP address).
If you ssh to another device in your LAN, can you accidentally connect through a less direct pathway (WAN)?
1,561,648,719,000
In ssh configuration directory, the file known_hosts stores for each server the (IP, fingerprint) couple. A server is trusted only if it matches both the elements of one of the couples in known_hosts. I need to connect to a Nitrux 1.1.4 Linux server (based on kernel 4.14.15-041415-generic) which for several reasons is forced to use DHCP. Its IP may vary even several times per day. Each of these times, I must accept a new couple (IP, fingerprint), flooding known_hosts. This solution is also quite unuseful. Is it possible to trust this host only considering its fingerprint, regardless of its IP? As in a previous question, I am using these clients: OpenSSH_7.8p1, OpenSSL 1.1.1a-freebsd 20 Nov 2018 and OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017.
A server is trusted when it matches the pattern before the fingerprint hash. ssh just adds both hostname and IP by default which requires to match both of them. Nothing holds you from editing known_hosts manually and replace IP with a mask (recommended) or remove IP at all (less secure way). So the entry in known_hosts would look like: hostname,192.168.1.* ssh-rsa AAAAhash== another-hostname ssh-rsa AAAAhash== both would work for you. You can find more detailed info in man sshd (section: SSH_KNOWN_HOSTS FILE FORMAT)
ssh, trust hosts on fingerprint basis only, regardless of IP
1,561,648,719,000
I have docker running on a synology nas. The nas has a private network (172.17.0.0/16) where docker places the containers. It also has a public facing interface on my lan, call it 10.11.12.10/24. internet ^ | | +----+------+ | pfSense | +-----+-----+ | +-----+-----+ | switch | +-+-------+-+ | | | | +---+--+ +-+---+ +------->| AP | | NAS | | +------+ +--+--+ | | +-----+--+ +--+--------+ | laptop | | container | +--------+ +-----------+ It is totally possible to set up port forwarding from the lan interface to a docker container and access ssh on a container that way, but I was feeling lazy so I thought I could just add a route in my pfsense firewall that would redirect all traffic to 172.17.0.0/16 from my lan directly to the nas. The route seem to work, it is possible to ssh to docker containers directly from my lan. But no such ssh session can live longer than 45 seconds. ➜ ~ date; ssh 172.17.0.2 -l root Wed Oct 10 21:19:32 CEST 2018 Last login: Wed Oct 10 19:16:07 2018 from 10.11.12.182 root@ubuntu1:~# while true; do date; sleep 5; done Wed Oct 10 19:19:42 UTC 2018 Wed Oct 10 19:19:47 UTC 2018 Wed Oct 10 19:19:52 UTC 2018 Wed Oct 10 19:19:57 UTC 2018 Wed Oct 10 19:20:02 UTC 2018 Wed Oct 10 19:20:07 UTC 2018 packet_write_wait: Connection to 172.17.0.2 port 22: Broken pipe ➜ ~ ➜ ~ The last packets before it stops seen with tcpdump on the laptop looks like this: 16:38:59.072210 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633305, win 5348, options [nop,nop,TS val 561669488 ecr 134368964], length 0 16:38:59.103814 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [.], seq 9633305:9634753, ack 5966, win 199, options [nop,nop,TS val 134369004 ecr 561669467], length 1448 16:38:59.225048 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561669637 ecr 134369004], length 0 16:38:59.324726 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134369225 ecr 561669467], length 1448 16:38:59.324789 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561669736 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:00.035790 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134369666 ecr 561669467], length 1448 16:39:00.035854 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561670445 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:00.751550 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134370548 ecr 561669467], length 1448 16:39:00.751642 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561671159 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:02.493382 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134372312 ecr 561669467], length 1448 16:39:02.493451 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561672900 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:06.179874 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134375840 ecr 561669467], length 1448 16:39:06.179964 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561676574 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:13.249689 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134382896 ecr 561669467], length 1448 16:39:13.249741 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561683642 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:27.376570 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134396992 ecr 561669467], length 1448 16:39:27.376645 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561697743 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 Corresponding tcpdump on pfsense only see traffic from the laptop as replies does not need to be routed 16:38:59.083374 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9632853, win 5358, options [nop,nop,TS val 561669485 ecr 134368962], length 0 16:38:59.083422 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9632905, win 5361, options [nop,nop,TS val 561669488 ecr 134368962], length 0 16:38:59.083471 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9632957, win 5359, options [nop,nop,TS val 561669488 ecr 134368962], length 0 16:38:59.083510 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633001, win 5358, options [nop,nop,TS val 561669488 ecr 134368963], length 0 16:38:59.083542 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633053, win 5356, options [nop,nop,TS val 561669488 ecr 134368963], length 0 16:38:59.083581 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633105, win 5355, options [nop,nop,TS val 561669488 ecr 134368963], length 0 16:38:59.083680 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633157, win 5353, options [nop,nop,TS val 561669488 ecr 134368963], length 0 16:38:59.083731 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633209, win 5351, options [nop,nop,TS val 561669488 ecr 134368964], length 0 16:38:59.083778 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633261, win 5350, options [nop,nop,TS val 561669488 ecr 134368964], length 0 16:38:59.083824 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9633305, win 5348, options [nop,nop,TS val 561669488 ecr 134368964], length 0 16:38:59.228487 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561669637 ecr 134369004], length 0 16:38:59.328679 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561669736 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:00.039683 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561670445 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:00.755280 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561671159 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:02.497019 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561672900 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:06.183600 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561676574 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:13.255414 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561683642 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 16:39:27.380228 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9634753, win 5363, options [nop,nop,TS val 561697743 ecr 134369004,nop,nop,sack 1 {9628757:9630205}], length 0 The nas sees the following 16:38:59.061977 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632365:9632409, ack 5966, win 199, options [nop,nop,TS val 134368960 ecr 561669467], length 44 16:38:59.062027 IP 10.11.12.182.64941 > 172.17.0.2.22: Flags [.], ack 9628757, win 5360, options [nop,nop,TS val 561669467 ecr 134368941], length 0 16:38:59.062216 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632409:9632453, ack 5966, win 199, options [nop,nop,TS val 134368960 ecr 561669467], length 44 16:38:59.062437 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632453:9632505, ack 5966, win 199, options [nop,nop,TS val 134368961 ecr 561669467], length 52 16:38:59.062620 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632505:9632549, ack 5966, win 199, options [nop,nop,TS val 134368961 ecr 561669467], length 44 16:38:59.062837 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632549:9632601, ack 5966, win 199, options [nop,nop,TS val 134368961 ecr 561669467], length 52 16:38:59.062984 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632601:9632653, ack 5966, win 199, options [nop,nop,TS val 134368961 ecr 561669467], length 52 16:38:59.063200 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632653:9632697, ack 5966, win 199, options [nop,nop,TS val 134368961 ecr 561669467], length 44 16:38:59.063401 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632697:9632749, ack 5966, win 199, options [nop,nop,TS val 134368962 ecr 561669467], length 52 16:38:59.063605 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632749:9632801, ack 5966, win 199, options [nop,nop,TS val 134368962 ecr 561669467], length 52 16:38:59.063800 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632801:9632853, ack 5966, win 199, options [nop,nop,TS val 134368962 ecr 561669467], length 52 16:38:59.064021 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632853:9632905, ack 5966, win 199, options [nop,nop,TS val 134368962 ecr 561669467], length 52 16:38:59.064220 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632905:9632957, ack 5966, win 199, options [nop,nop,TS val 134368962 ecr 561669467], length 52 16:38:59.064447 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9632957:9633001, ack 5966, win 199, options [nop,nop,TS val 134368963 ecr 561669467], length 44 16:38:59.064698 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9633001:9633053, ack 5966, win 199, options [nop,nop,TS val 134368963 ecr 561669467], length 52 16:38:59.064938 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9633053:9633105, ack 5966, win 199, options [nop,nop,TS val 134368963 ecr 561669467], length 52 16:38:59.065172 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9633105:9633157, ack 5966, win 199, options [nop,nop,TS val 134368963 ecr 561669467], length 52 16:38:59.065422 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9633157:9633209, ack 5966, win 199, options [nop,nop,TS val 134368964 ecr 561669467], length 52 16:38:59.065663 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9633209:9633261, ack 5966, win 199, options [nop,nop,TS val 134368964 ecr 561669467], length 52 16:38:59.065880 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9633261:9633305, ack 5966, win 199, options [nop,nop,TS val 134368964 ecr 561669467], length 44 16:38:59.105416 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [.], seq 9633305:9634753, ack 5966, win 199, options [nop,nop,TS val 134369004 ecr 561669467], length 1448 16:38:59.326452 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134369225 ecr 561669467], length 1448 16:38:59.767432 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134369666 ecr 561669467], length 1448 16:39:00.649466 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134370548 ecr 561669467], length 1448 16:39:02.413454 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134372312 ecr 561669467], length 1448 16:39:05.941490 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134375840 ecr 561669467], length 1448 16:39:12.997468 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134382896 ecr 561669467], length 1448 16:39:27.093471 IP 172.17.0.2.22 > 10.11.12.182.64941: Flags [P.], seq 9628757:9630205, ack 5966, win 199, options [nop,nop,TS val 134396992 ecr 561669467], length 1448 I'm not sure I read it right, but the last few packages have the same ack/seq values. Leading me to believe that both nodes see each others packets but are unable to realise that the packets are part of the same session. Any idea?
Adding the route to the pfsense makes the traffic flow weird. Traffic from the laptop bounces over the pfsense, back down to the nas and then to the container. Replies from the container however will go via the nas directly to the laptop on layer 2. No routing needed. A consequence of that is that the firewall on the nas that only allow related packages get confused and invalidates the relation between the ssh packages and the first ssh connect packet. My guess is that iptables conntrack on the nas is killing the session. # iptables -S -P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT -N DEFAULT_FORWARD -N DOCKER -N DOCKER-ISOLATION -A FORWARD -j DEFAULT_FORWARD -A DEFAULT_FORWARD -j DOCKER-ISOLATION -A DEFAULT_FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A DEFAULT_FORWARD -o docker0 -j DOCKER -A DEFAULT_FORWARD -i docker0 ! -o docker0 -j ACCEPT -A DEFAULT_FORWARD -i docker0 -o docker0 -j ACCEPT -A DOCKER-ISOLATION -j RETURN Removing the route from the pfsense and configuring it directly on the laptop instead seem to work a lot better. How to add route on macOS: sudo route add 172.17.0.0/16 10.11.12.10
ssh to docker container breaks after 45 seconds
1,561,648,719,000
I seem to be not able to generate a RSA-4096 SSH key in OpenSSH's new key format with the following command: $ ssh-keygen \ -f rsa4096_key \ -t rsa \ -b 4096 \ -C 'This is a test' \ -o \ -N '' At least I get the following error message after trying to change the existing comment of the RSA-4096 SSH key: $ ssh-keygen -cf rsa4096_key Comments are only supported for keys stored in the new format (-o). So even though I specified the -o flag during key generation the RSA-4096 SSH key seems to be written in the old PEM key format instead of OpenSSH's new key format. N.B. For an Ed25519 SSH key I'm able to retroactively change its comment. According to the manpage SSH-KEYGEN(1) of OpenSSH version OpenSSH_7.7p1: -o Causes ssh-keygen to save private keys using the new OpenSSH format rather than the more compatible PEM format. The new format has increased resistance to brute-force password cracking but is not supported by versions of OpenSSH prior to 6.5. Ed25519 keys always use the new private key format. Does someone has a solution to this problem or can tell me what I did wrong? Thanks! Update: The solution proposed by @slm works for me albeit the misleading manpage and confusing console output. Basically the command: $ ssh-keygen -f rsa4096_key -o -c -C 'here goes your comment' Key now has comment 'This is a test' The comment in your key file has been changed. When run again it proves that it changed the comment to the one given on the previous command line: $ ssh-keygen -f rsa4096_key -o -c -C 'Hello World!' Key now has comment 'here goes your comment' The comment in your key file has been changed. Therefore I accepted @slm's answer.
I think this is a bug in both the -o switches behavior as well as a documentation bug in OpenSSH. This works for me: $ ssh-keygen \ -f rsa4096_key \ -t rsa \ -b 4096 \ -C 'This is a test' \ -o \ -N '' $ grep -o "This.*" rsa4096_key.pub This is a test So the comment is getting stored in the rsa4096_key.pub file. Since the .pub file can always be extracted from the private key, it's by definition in the private key file as well. This SU Q&A titled: How can I change the comment field of an RSA key (SSH)? shows some analysis around this. Also there's a comment on this SF Q&A titled: Possible to change email address in keypair?. Mainly: From OpenSSH 6.5 onwards, works with all key types, not just RSA1: ssh-keygen -f ~/.ssh/keyfilename -o -c -C "here goes your comment" -f: private key file -o: convert the private key from PEM to the new OpenSSH format -c: change the comment in the private and public key files -C: comment text References Output when changing comment is weird and badly documented
How to store RSA-4096 SSH key in OpenSSH's new key format
1,561,648,719,000
How to create a (username/password or certificate) white/black list for ssh? For example of blacklist, I can use any username/password combination to access the server, except the ones on the blacklist. The ssh version can be OpenSSH. And the server is a Linux. Creating lots of users on Linux for white list is not a nice way. Any approach can be used, like modifying SSH software itself, or using Linux/SSH features, or using other modules. Update: Maybe I did not describe the situation clearly. Basically, I simply want any username/password combination to be able to login, except the black list. For example, if the black list is "admin/admin; root/123". I can simply use "abc/123456" to login. The server is like a VERY VULNERABLE one with almost no credential needed. For white list, I can give a number of username/password/certificate combinations for the list, not just the username.
For a blacklist, in your sshd_config add the DenyUsers entry followed by a list of users separated by a space. You can also use DenyGroups in a similar fashion. For example: DenyUsers jimmy bill joe susan or DenyGroups teachers A whitelist is created by using the AllowUsers and/or AllowGroups entries in the sshd_config file. If either of these entries is used, only those users or groups listed will be permitted to login.
White List and Black List for SSH
1,561,648,719,000
When I attempt to log in to a CentOS box via ssh, it hangs after putting in the password. I can get in to the system via console and when i run w I can see "cvs server" running for the user trying to login. USER TTY FROM LOGIN IDLE PCPU WHAT root pts/1 systemname 11:37 1:14m 0.00s cvs server In the secure logs it looks like it was a valid login: Accept password for root from 172.0.0.17 port 53270 ssh2 pam_unix(sshd:session): session opened for user root by (uid=0) It appears like a normal login, but it will never actually give me the prompt. I've tried restarting the SSHD service, same issues. This is a production box so im a little hesitant to reboot it. I can't seem to find anything in the log files that looks suspect. When I run ssh -vvv and try to connect, it also looks fine but I never get the login message after "request accepting on channel.." Here is the paste of the end of -vvv: debug2: channel 1: request shell confirm 1 debug3: send packet: type 98 debug2: callback done debug2: channel 1: open confirm rwindow 0 rmax 32768 debug3: receive packet: type 99 debug2: channel_input_status_confirm: type 99 id 1 debug2: PTY allocation request accepted on channel 1 debug2: channel 1: rcvd adjust 2097152 debug3: receive packet: type 99 debug2: channel_input_status_confirm: type 99 id 1 debug2: shell request accepted on channel 1 Also, I went through the network firewall to see if maybe it was dropping packets or something, nothing like that is happening. I also tried from some other system, same issue. I've never seen this before and can't seem to find any good info on this exact issue. Any help, most appreciated! EDIT: I only have a root account on here and there is no .bashrc or .bash_profile that I can find in root, or anywhere else. However, I do see an cvs.sh and a cvs.csh in /etc/profile.d/. I did see a for loop in /etc/profile/ that is looking for scripts in /etc/profile.d/ to run at startup. Here are the contents of those scripts: cvs.sh # change default from rsh to ssh for cvs command export CVS_RSH=${CVS_RSH-ssh} cvs.csh # change default from rsh to ssh for cvs command if ( "$?CVS_RSH" == 0 ) setenv CVS_RSH ssh I thought maybe it was looking for cvs and also server but I don't see anything with server in the script directory. Is there somewhere else I should be looking? All the normal places ive seen profile files, nothing is there. Thanks!
I have found the troublemaker. There was an old entry in sshd_config that contained ForceCommand cvs server. Once I adjusted the comment mark and restart the service, I was able to log in just fine. I actually went through this file at first but didn't check everything bit by bit. Could have saved me an hour or 2 to be thorough off the bat...
SSH hangs on login, shows "cvs server" as the hung process for the user
1,561,648,719,000
I know that it was not a good idea to do update OpenSSH to v. 7.6 on Centos 6.9, but it was done. So now I can't connect to the server by ssh. Trying to login with key: debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 60 debug1: Server accepts key: pkalg rsa-sha2-512 blen 279 debug2: input_userauth_pk_ok: fp SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxx debug3: sign_and_send_pubkey: RSA SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxx debug3: send packet: type 50 Authentication failed. Trying to login with root password: debug2: we sent a password packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-with-mic,password Permission denied, please try again. Anything else possible to do to fix this or downgrade openssh? p.s. I'm connecting from MacOs with OpenSSH_7.5p1 and from CentOs 7 with OpenSSH_7.4p1, so my problem is not in legacy issue. Thanks!
So first of all, OpenSSH update is overwrite sshd_config file make not possible to login into the system by root (so if you do update for OpenSSH from a source - don't forget to check sshd_config before logout). But I was able to use Parallels VM Console to connect and change sshd_config but still get the same issue with connection. The second issue what I meet is that PAM configs for sshd (/etc/pam.d/sshd) were not updated and requested old files openssh PAM unable to dlopen(/lib64/security/pam_stack.so): /lib64/security/pam_stack.so: cannot open shared object file: No such file or directory I tried first to use solutions which I found on the internet for this case, but at the end, I change sshd use same configs from another server with Centos7: #%PAM-1.0 auth required pam_sepermit.so auth substack password-auth auth include postlogin # Used with polkit to reauthorize users in remote sessions -auth optional pam_reauthorize.so prepare account required pam_nologin.so account include password-auth password include password-auth # pam_selinux.so close should be the first session rule session required pam_selinux.so close session required pam_loginuid.so # pam_selinux.so open should only be followed by sessions to be executed in the user context session required pam_selinux.so open env_params session required pam_namespace.so session optional pam_keyinit.so force revoke session include password-auth session include postlogin # Used with polkit to reauthorize users in remote sessions -session optional pam_reauthorize.so prepare After this changes, I was able to login into the system.
Can't connect to Centos 6.9 after update to OpenSSH 7.6 on this server [duplicate]
1,561,648,719,000
I have an old Linux box (version 2.6.12, compiled by a colleague) behind an NAT-enabled router, that I want to access from a remote PC. There's an SSH daemon running on the box, but since there was no SSH client yet, we compiled an old Dropbear client, which works fine when creating a tunnel. I should note that the SSH daemon is running on port 55000 and that the version of the Dropbear client is v0.53. The problem arises, however, when using remote port forwarding: ./dbclient -N -R myserver.com:10022:localhost:55000 [email protected] This prompts me for a password, and from myserver.com, I can see the connection was successful: sudo netstat -tulpn | grep 10022 tcp 0 0 xx.xx.xx.xx:10022 0.0.0.0:* LISTEN 31512/sshd: me When trying to use the tunnel from my Mac or Ubuntu (OpenSSH_7.4p1, LibreSSL 2.5.0), however, not much is happening. ssh -p 10022 [email protected] Just hangs forever. The user 'test' exists on my Linux box. In verbose mode, I get the following: ssh -p 10022 [email protected] -v OpenSSH_7.4p1, LibreSSL 2.5.0 debug1: Reading configuration data /Users/me/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to myserver.com [xx.xx.xx.xx] port 10022. debug1: Connection established. debug1: identity file /Users/me/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/me/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4 My knowledge of SSH is fairly basic and remote forwarding is very new to me, so I have no idea what to try next. I've tried a Dropbear client on Ubuntu and Mac, which just hangs as well. I don't think it has a verbose mode(?). I tried the reverse, i.e. setting up remote port forwarding in Ubuntu and then connecting from the Linux box and that just works. Is it just some configuration problem? Could it be that the SSH daemon is not welcoming my connections and how could I check or fix that? Do I need an older SSH client on my PC's? Any help is greatly appreciated! EDIT: does sshd require any special configuration parameters or does this have nothing to do with sshd?
This will definitely not be the solution for most, but I'll post it here anyway, maybe it can help someone else in the future. The problem was that on the Linux box, the loopback interface was down by default. I'm still not sure why. I figured it out by trying to SSH to localhost, which failed. Pinging didn't work either. After bringing up the loopback, everything worked: ifconfig lo up (The name of your loopback interface might be different, it depends on your OS) I can only assume that behind the scenes, a local SSH connection is being made from the forwarding tunnel to the local SSH daemon.
SSH to older Linux box using remote port forwarding
1,561,648,719,000
I'm trying to connect to myself through ssh. (For testing purpose). I'm on a Ubuntu laptop. I successfully launched a ssh serveur, and "ssh localhost" works fine. If I try "ssh ", it works too. (I got it from ifconfig) But if I try with my public IP adress (got it on whatismyipadress.com), it doesn't work, I get a timeout after 2 minutes. (Note that "ping " works fine) Any idea about why I get this ? I wouldn't be surprised if the problem came from my router (or is it a modem, or something like that ? I don't know), which would be working fine but have no idea about where to redirect ssh request (maybe on a computer from home which doesn't run ssh server ?)
As @Findus23 says, you have to forward a port (different from the 22, which is perhaps used as default port to connect to SSH router itself) from the router to your PC. I make an example: PC [192.168.1.10] <==> [192.168.1.1] Router [1.1.1.1] <==> Internet As you can see, connecting through SSH to the address 1.1.1.1 results in connecting to the port 22 of your router on his public interface (faced to Internet). If you want to access a PC located behind the router (so, in the private network of address space 192.168.1.0/24) you have to enable Port Forwarding. This is mandatory because your router must know which host it has to contact from the full address space of PCs connected to it. For example: (PC1[192.168.1.2], PC2[192.168.1.3]) <==> Router Router cannot know if it has to route to PC1 or PC2 when contacted to a specified port. Enabling Port Forwarding you can say: All connections from Internet to port X of the router, must be routed to port Y of PCZ So, in your case: Router:<port> => PC1:22 (route connection from router port 4000 to port 22 of PC1) ssh -p <port> user@<router-IP> results in connecting, from Internet, to the specified local host.
Can't ssh to myself through internet?
1,561,648,719,000
This question is actually too broad... What I really want to know is whether or not it actually chroots and, if so, how a SSH user deamon[1] can be launched in that jail in spite of the obvious lack of the required binary/lib in the chroot. Google is surprisingly silent on the matter. But a good reference to explain that woud be enough (however I'm not litterate enough to read and understand their C). [1]: I'm talking about the actual transient daemon with user priviledges that is launched upon connection by the main root OpenSSH daemon.
The other answer is quite vague (also the question is) so I will try to be more verbose about this phenomen. I know that this topic is not for everybody, but for these interested it is quite nice thing to know about. There are two different places where the chroot is done and you are poking into both of them so I will try to align your ideas: There is privilege separation, which is security mechanism and part of it is also chroot as a limitation of network child. This is usually some empty directory, like /var/empty. The reason is in few words, that if there was some vulnerability, it would be probably not exploitable, because this process doesn't see filesystem and is also limited in other ways (sandbox, SECCOMP keywords for further readings). Later on you can chroot the user's session (not only SFTP) in specific directory to prevent access to whole filesystem. This is probably the part you are interested, based on the title. The magic about sftp in chroot is that you can specify Subsystem sftp internal-sftp (instead of the full path Subsystem sftp /usr/lib/openssh/sftp-server). This implies that sshd has whole sftp-server compiled-in and instead of exec on the binary, it just calls function where the server behaviour is defined. This doesn't require any supporting files in chroot for user (unlike the normal session, where you need shell and its dependent shared objects). You may also require logging socket, if you are interested in such informations.
How is OpenSSH sftp jail/chroot working?
1,561,648,719,000
I'm trying to configure the following restrictions in my sshd_config: Users with local IP addresses face no restrictions Users with non-local IP addresses, who are in the sftp group, are allowed to use sftp in a chroot jail Users with non-local IP addresses, who are not in the sftp group, are not allowed to do anything. Here's what I came up with: Match Address 10.0.0.0/24,172.16.0.0/20,192.168.0.0/16 X11Forwarding yes Match Address *,!10.0.0.0/24,!172.16.0.0/20,!192.168.0.0/16 Group sftp X11Forwarding no AllowTcpForwarding no ChrootDirectory %h ForceCommand internal-sftp Match Address *,!10.0.0.0/24,!172.16.0.0/20,!192.168.0.0/16 Group *,!sftp X11Forwarding no AllowTcpForwarding no ForceCommand /sbin/nologin The problem: when I try to login from an internal address, as a non-sftp user, I get rejected; the third Match triggered. According to the sshd_config manpage, a Match is only satisfied if all of its clauses are satisfied, but in my case, the first clause is not satisfied (I am coming in from a machine with a 172.16.0.0/20 IP address), only the second one is (I am not in the sftp group). Is the sshd_config manpage wrong? Is it possible to do what I am trying to do? UPDATE: at @steve's suggestion, I ran sshd in debug mode, and got this: debug1: userauth-request for user root service ssh-connection method none debug1: attempt 0 failures 0 debug1: connection from 172.19.187.49 matched 'Address *,!10.0.0.0/24,!172.16.0.0/20,!192.168.0.0/16' at line 144 debug1: user root does not match group list sftp at line 144 debug1: connection from 172.19.187.49 matched 'Address *,!10.0.0.0/24,!172.16.0.0/20,!192.168.0.0/16' at line 150 debug1: user root matched group list *,!sftp at line 150 debug1: PAM: initializing for "root" The no-internal-adress clauses are matching; also, the first Match is not mentioned in the debug log, which seems odd. UPDATE: As @Gilles pointed out, my address specifications as shown above are incorrect. What I should have used was 10.0.0.0/8, not 10.0.0.0/24, and 172.16.0.0/12, not 172.16.0.0/20. I was counting the mask bits down from 32 instead of up from 0. Yikes. With the corrected addresses, the configuration works. Thanks Gilles and Uriel! (I also changed the /sbin/nologin in the last line to /bin/false; the former leads to a strange error message from sftp: Received message too long 1416128883.)
Your netmaks are incorrect. If you want to include private networks, you should use : 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 This is probably why you do not match, rather than a ssh bug.
Unexpected Match behavior in sshd_config
1,561,648,719,000
New installation of RHEL8 with openssh-server installed, enabled, and running. firewall-cmd shows service ssh is added: [[email protected] ]# firewall-cmd --list-services cockpit ssh netstat -anp | grep 22 shows the server is listening over 0:0:0:0:22 service sshd status shows the same (listening on port 22) nmap -sSV -O -p 22 localhost (issued from new.rhel.server) shows that port 22 is open. I am able to ssh localhost on new.rhel.server successfully. The server has internet connectivity. When I try to ssh [email protected], I get an immediate Connection Refused error. me@laptop ~ $ ssh -vvv new.rhel.server OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f 31 Mar 2020 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug2: resolving "new.rhel.server" port 22 debug2: ssh_connect_direct debug1: Connecting to new.rhel.server [1.2.3.4] port 22. debug1: connect to address 1.2.3.4 port 22: Connection refused ssh: connect to host new.rhel.server port 22: Connection refused nmap -sSV -O -p 22 new.rhel.server (issued from my laptop) shows that port 22 is actually closed: Starting Nmap 7.80 ( https://nmap.org ) at 2022-09-21 17:27 EDT Nmap scan report for new.rhel.server (1.2.3.4) Host is up (0.000051s latency). PORT STATE SERVICE VERSION 22/tcp closed ssh Too many fingerprints match this host to give specific OS details Network Distance: 0 hops OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 2.05 seconds This has me stumped. Why would nmap show the port is closed while the server reports that the port is open?
This is now working. For unknown reasons, the Port line in sshd_config was commented out. # If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER # #Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: Changing that to # Port 22 #AddressFamily any then restarting sshd fixed this issue. This was a fresh installation of RHEL, not sure why the Port line was commented out by default.
firewall-cmd shows ssh enabled, but nmap from client shows port 22 closed (Connection Refused)
1,561,648,719,000
I'm trying to ssh to my local sshd, but the connection is detected by sshd it closes before I get a password prompt. The server is running buildroot and uses glibc. I've compared the logs with working ssh/sshd logs, but the only difference I can find is the sudden exit after the method 'none', which does not give me any leads. I've tried poking around in the file system to check for missing files or invalid file properties. I've also tried invoking it directly instead of running it as a systemd service. sshd output: Started OpenSSH server daemon. debug2: load_server_config: filename /etc/ssh/sshd_config debug2: load_server_config: done config len = 336 debug2: parse_server_config_depth: config /etc/ssh/sshd_config len 336 debug3: /etc/ssh/sshd_config:18 setting HostKey /static/etc/ssh/ssh_host_rsa_key debug3: /etc/ssh/sshd_config:19 setting HostKey /static/etc/ssh/ssh_host_dsa_key debug3: /etc/ssh/sshd_config:20 setting HostKey /static/etc/ssh/ssh_host_ecdsa_key debug3: /etc/ssh/sshd_config:32 setting PermitRootLogin yes debug3: /etc/ssh/sshd_config:41 setting AuthorizedKeysFile .ssh/authorized_keys debug3: /etc/ssh/sshd_config:108 setting Subsystem sftp /usr/libexec/sftp-server debug1: sshd version OpenSSH_8.6, OpenSSL 1.1.1k 25 Mar 2021 debug1: private host key #0: ssh-rsa SHA256:FLrw6X2h9xj+aa2GQduIb1QCAzbI1ooWNyD86gA2iV8 debug1: private host key #1: ssh-dss SHA256:q6emWCLwbPVmiHfiAjLhgximILI+jvmNjxmvIHT3upQ debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:efea0vwUrNps9M0NMoj4G7XpnGWHXnnEHlSWqbg9fX0 debug1: rexec_argv[0]='/usr/sbin/sshd' debug1: rexec_argv[1]='-D' debug1: rexec_argv[2]='-e' debug1: rexec_argv[3]='-ddd' debug3: already daemonized debug3: oom_adjust_setup debug1: Set /proc/self/oom_score_adj from 0 to -1000 debug2: fd 3 setting O_NONBLOCK debug1: Bind to port 22 on 0.0.0.0. Server listening on 0.0.0.0 port 22. debug2: fd 4 setting O_NONBLOCK debug3: sock_set_v6only: set socket 4 IPV6_V6ONLY debug1: Bind to port 22 on ::. Server listening on :: port 22. debug3: fd 5 is not O_NONBLOCK debug1: Server will not fork when running in debugging mode. debug3: send_rexec_state: entering fd = 8 config len 336 debug3: ssh_msg_send: type 0 debug3: send_rexec_state: done debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8 debug3: recv_rexec_state: entering fd = 5 debug3: ssh_msg_recv entering debug3: recv_rexec_state: done debug2: parse_server_config_depth: config rexec len 336 debug3: rexec:18 setting HostKey /static/etc/ssh/ssh_host_rsa_key debug3: rexec:19 setting HostKey /static/etc/ssh/ssh_host_dsa_key debug3: rexec:20 setting HostKey /static/etc/ssh/ssh_host_ecdsa_key debug3: rexec:32 setting PermitRootLogin yes debug3: rexec:41 setting AuthorizedKeysFile .ssh/authorized_keys debug3: rexec:108 setting Subsystem sftp /usr/libexec/sftp-server debug1: sshd version OpenSSH_8.6, OpenSSL 1.1.1k 25 Mar 2021 debug1: private host key #0: ssh-rsa SHA256:FLrw6X2h9xj+aa2GQduIb1QCAzbI1ooWNyD86gA2iV8 debug1: private host key #1: ssh-dss SHA256:q6emWCLwbPVmiHfiAjLhgximILI+jvmNjxmvIHT3upQ debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:efea0vwUrNps9M0NMoj4G7XpnGWHXnnEHlSWqbg9fX0 debug3: already daemonized debug1: inetd sockets after dupping: 3, 3 Connection from 127.0.0.1 port 47472 on 127.0.0.1 port 22 debug1: Local version string SSH-2.0-OpenSSH_8.6 debug1: Remote protocol version 2.0, remote software version OpenSSH_8.6 debug1: compat_banner: match: OpenSSH_8.6 pat OpenSSH* compat 0x04000000 debug2: fd 3 setting O_NONBLOCK debug3: ssh_sandbox_init: preparing seccomp filter sandbox debug2: Network child is on pid 17115 debug3: preauth child monitor started debug3: privsep user:group 1001:1001 [preauth] debug1: permanently_set_uid: 1001/1001 [preauth] debug3: ssh_sandbox_child: setting PR_SET_NO_NEW_PRIVS [preauth] debug3: ssh_sandbox_child: attaching seccomp filter program [preauth] debug3: append_hostkey_type: ssh-dss key not permitted by HostkeyAlgorithms [preauth] debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256 [preauth] debug3: send packet: type 20 [preauth] debug1: SSH2_MSG_KEXINIT sent [preauth] debug3: receive packet: type 20 [preauth] debug1: SSH2_MSG_KEXINIT received [preauth] debug2: local server KEXINIT proposal [preauth] debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha> debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256 [preauth] debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] [preauth] debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] [preauth] debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],umac-64> debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],umac-64> debug2: compression ctos: none,[email protected] [preauth] debug2: compression stoc: none,[email protected] [preauth] debug2: languages ctos: [preauth] debug2: languages stoc: [preauth] debug2: first_kex_follows 0 [preauth] debug2: reserved 0 [preauth] debug2: peer client KEXINIT proposal [preauth] debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha> debug2: host key algorithms: [email protected],ecdsa-sha2-nistp256,[email protected],[email protected]> debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] [preauth] debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] [preauth] debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],umac-64> debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],umac-64> debug2: compression ctos: none,[email protected],zlib [preauth] debug2: compression stoc: none,[email protected],zlib [preauth] debug2: languages ctos: [preauth] debug2: languages stoc: [preauth] debug2: first_kex_follows 0 [preauth] debug2: reserved 0 [preauth] debug1: kex: algorithm: curve25519-sha256 [preauth] debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth] debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none [preauth] debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none [preauth] debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth] debug3: receive packet: type 30 [preauth] debug1: SSH2_MSG_KEX_ECDH_INIT received [preauth] debug3: mm_sshkey_sign: entering [preauth] debug3: mm_request_send: entering, type 6 [preauth] debug3: mm_request_receive: entering debug3: monitor_read: checking request 6 debug3: mm_answer_sign: entering debug3: mm_answer_sign: KEX signature 0x4f8e80(101) debug3: mm_request_send: entering, type 7 debug2: monitor_read: 6 used once, disabling now debug3: mm_sshkey_sign: waiting for MONITOR_ANS_SIGN [preauth] debug3: mm_request_receive_expect: entering, type 7 [preauth] debug3: mm_request_receive: entering [preauth] debug3: send packet: type 31 [preauth] debug3: send packet: type 21 [preauth] debug2: set_newkeys: mode 1 [preauth] debug1: rekey out after 134217728 blocks [preauth] debug1: SSH2_MSG_NEWKEYS sent [preauth] debug1: Sending SSH2_MSG_EXT_INFO [preauth] debug3: send packet: type 7 [preauth] debug1: expecting SSH2_MSG_NEWKEYS [preauth] debug3: receive packet: type 21 [preauth] debug1: SSH2_MSG_NEWKEYS received [preauth] debug2: set_newkeys: mode 0 [preauth] debug1: rekey in after 134217728 blocks [preauth] debug1: KEX done [preauth] debug3: receive packet: type 5 [preauth] debug3: send packet: type 6 [preauth] debug3: receive packet: type 50 [preauth] debug1: userauth-request for user root service ssh-connection method none [preauth] debug1: attempt 0 failures 0 [preauth] debug3: mm_getpwnamallow: entering [preauth] debug3: mm_request_send: entering, type 8 [preauth] debug3: mm_getpwnamallow: waiting for MONITOR_ANS_PWNAM [preauth] debug3: mm_request_receive_expect: entering, type 9 [preauth] debug3: mm_request_receive: entering [preauth] debug3: mm_request_receive: entering debug3: monitor_read: checking request 8 debug3: mm_answer_pwnamallow: entering debug2: parse_server_config_depth: config reprocess config len 336 debug3: auth_shadow_acctexpired: today 18864 sp_expire -1 days left -18865 debug3: account expiration disabled debug3: mm_answer_pwnamallow: sending MONITOR_ANS_PWNAM: 1 debug3: mm_request_send: entering, type 9 debug2: monitor_read: 8 used once, disabling now debug2: input_userauth_request: setting up authctxt for root [preauth] debug3: mm_inform_authserv: entering [preauth] debug3: mm_request_send: entering, type 4 [preauth] debug2: input_userauth_request: try method none [preauth] debug3: mm_request_receive: entering debug3: monitor_read: checking request 4 debug3: mm_answer_authserv: service=ssh-connection, style= debug2: monitor_read: 4 used once, disabling now debug3: user_specific_delay: user specific delay 0.000ms [preauth] debug3: ensure_minimum_time_since: elapsed 28.499ms, delaying 26.813ms (requested 6.914ms) [preauth] debug1: monitor_read_log: child log fd closed debug3: mm_request_receive: entering debug1: do_cleanup debug1: Killing privsep child 17115 The /etc/ssh/sshd_config # $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/bin:/sbin:/usr/bin:/usr/sbin # 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 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: HostKey /static/etc/ssh/ssh_host_rsa_key HostKey /static/etc/ssh/ssh_host_dsa_key HostKey /static/etc/ssh/ssh_host_ecdsa_key # Ciphers and keying #RekeyLimit default none # Logging #SyslogFacility AUTH #LogLevel INFO # Authentication: #LoginGraceTime 2m PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #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 yes # Change to no to disable s/key passwords #ChallengeResponseAuthentication 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 ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication 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 ChallengeResponseAuthentication to 'no'. #UsePAM no #AllowAgentForwarding yes #AllowTcpForwarding yes #GatewayPorts no #X11Forwarding no #X11DisplayOffset 10 #X11UseLocalhost yes #PermitTTY yes #PrintMotd yes #PrintLastLog yes #TCPKeepAlive yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #UseDNS no #PidFile /var/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/libexec/sftp-server # Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # PermitTTY no # ForceCommand cvs server
According to this buildroot issue the call to clock_nanosleep_time64 or clock_gettime64 is problematic and causes: The OpenSSH server on my device closes the connection abruptly I'm able to login after adding this patch to the openssh source code before building.
SSHD accepts connection but closes after method 'none'
1,561,648,719,000
I'm on OpenBSD 6.8 and am running OpenSSH 8.4. How do I upgrade to OpenSSH 8.6, the newest version? Based off of this page https://www.openssh.com/openbsd.html , I know where to download it from, just not how. Where do I extract the .tar.gz to? Are there other steps besides just restarting sshd?
OpenSSH is part of the OpenBSD base system. The components of the base system are never upgraded individually, but always as part of a full base system upgrade. It is possible (by patching the base system's source code), but you will not get help from official OpenBSD mailing lists for your Frankenstein-system, and I would strongly advice against it. There is nothing saying that the OpenSSH from the current snapshot would work at all with an otherwise stable (not snapshot) OpenBSD system. Having said that, the page that you link to seems to contain clear instructions on how to install the latest OpenSSH on top of a recent OpenBSD system. I doubt this is a recommended upgrade path though. In short, if you are using the -release or -stable branch of OpenBSD, you will get OpenSSH 8.6 when you upgrade your system to the OpenBSD 6.9 release, which currently is planned in for around May 1, 2021. If you are extremely eager to get OpenSSH 8.6, you can try the instructions you linked to, but you also have the option to upgrade the system to a snapshot release (but it would then be difficult to move the system back on to a stable release after that). In either case, it is the sysupgrade utility that is the most convenient to use to upgrade between stable releases, or between snapshots, provided you have a mostly default base system.
How to upgrade to newer OpenSSH version on OpenBSD
1,561,648,719,000
I have an SFTP server that runs on Amazon Linux 2 on AWS. The current SSH version is OpenSSH_7.4p1, is it possible to safely upgrade this to version 7.8. If yes how can I get it done. Since the SFTP server is already a production environment and has many users and applications connecting to it, I am worried if this upgrade might break anything. I need to upgrade due to a limitation in the current version. Update: I was able to upgrade to the required version. But, my service file seems to not start the sshd service. It instead displays "sshd.service start operation timed out. Terminating." However, the new ssh service starts and works when i manually execute /usr/sbin/sshd in the terminal. Can some one please help me at this point. Any hints here ?
This is solved. I followed the below blogs to complete and troubleshoot my openssh upgrade. I was doing it on amazon linux. However, I believe this should work on centos as well. https://www.tecmint.com/install-openssh-server-from-source-in-linux/ https://blog.jonkimi.com/2020/04/17/Upgrade-openssh-server-on-Ubuntu/ http://blog.chinaunix.net/uid-28813320-id-5786956.html
How can we safely upgrade SSH 7.4 to 7.8 on AmazonLinux2
1,561,648,719,000
I can't log into a clean Centos8 install on my VPS from the terminal using public key authentication. When logging in it seems to authenticate OK, but then it times-out then returns a "Connection reset by [remote host ip address]" (not peer). I've checked out all the logs. But nothing is really forthcoming. Things I've checked out: /var/log/messages /var/log/audit/audit.log /var/log/secure Permissions for ~/.ssh and ~/.ssh/id_rsa* files /etc/ssh/sshd_config I've tried logging in from different machines in my LAN without success: Ubuntu 18.04 CentOS 7 machine WSL It's worthwhile to note I have no problems logging into a clean CentOS7 install from the same VPS. Is there a change in OpenSSH 8 that I'm not aware of? I've attached verbose output for logging into a CentOS7 and CentOS8 system: CentOS 7 SSH OK: https://pastebin.com/uGc1T8tk CentOS 8 SSH Fail: https://pastebin.com/XadQQEBK As you can see authentication succeeds in both: debug1: Authentication succeeded (publickey) The main difference I can see in CentOS 8 is that it's now using OpenSSH 8 instead of OpenSSH 7 Is there a change in OpenSSH 8 that I'm not aware of? Thanks all in advance. Edit 1 @thehostingadmin I don't know how to copy n paste from the web GUI but here's the output from the command you provided: https://i.sstatic.net/9lJec.jpg Edit 2 # sysctl -w net.ipv4.tcp_tw_recycle=0 sysctl: cannot stat /proc/sys/net/ipv4/tcp_tw_recycle: No such file or directory # sysctl -w net.ipv4.tcp_tw_reuse=0 net.ipv4.tcp_tw_reuse = 0 Result: Still no dice Edit 3 Success/Fail Matrix | OS | SSH Client | Network | Auth | Success | |--------------------|---------------|--------------|------|------------| | Ubuntu 18.04 (WSL) | OpenSSH_7.6p1 | LAN (NAT x2) | OK | E01 | TO/H | | Debian 10 (RPi) | OpenSSH_7.9p1 | LAN (NAT x2) | OK | TO/H | | Ubuntu 18.04 | OpenSSH_7.6p1 | LAN (NAT x1) | OK | E02 | | CentOS 7.8 | OpenSSH_7.4p1 | LAN (NAT x1) | OK | TO/H | | CentOS 7.8 | OpenSSH_7.4p1 | VPS | OK | OK | E01: Connection reset by [remote host ip address] port 22 E02: packet_write_wait: Connection to [remote host ip address] port 22: Broken pipe TO/H: Timeout/Hang Edit 4 Made the following changes: # /etc/ssh/sshd_config TCPKeepAlive yes ClientAliveInterval 20 ClientAliveCountMax 5 No measurable difference. Edit 5 When ssh client throws error E01, I can see the following on the server: # journalctl -u systemd-logind -fn0 Aug 27 14:51:18 host systemd-logind[701]: New session 136 of user root. debug1: client_input_channel_req: channel 0 rtype [email protected] reply 1 Aug 27 14:51:38 host systemd-logind[701]: Session 136 logged out. Waiting for processes to exit. Aug 27 14:51:38 host systemd-logind[701]: Removed session 136. A successful login looks like this: Aug 27 15:04:42 host systemd-logind[701]: New session 143 of user root. Edit 6 I turned LogLevel to DEBUG3 and found the following in /var/log/secure # Login Fail Aug 27 15:59:07 host sshd[9387]: debug3: monitor_read: checking request 124 Aug 27 15:59:26 host sshd[9389]: Read error from remote host <wan ip> port 2611: Connection reset by peer Aug 27 15:59:26 host sshd[9389]: debug1: do_cleanup # Login Success Aug 27 15:57:48 host sshd[9360]: debug3: monitor_read: checking request 124 Edit 7 Apologies to @fra-san. Adding more verbose logging (-vvv) did provide more detail # SSH fail debug2: channel 0: request shell confirm 1 debug3: send packet: type 98 debug2: channel_input_open_confirmation: channel 0: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug3: send packet: type 1 Connection reset by <remote host ip> port 22 # SSH Success debug2: channel 0: request shell confirm 1 debug3: send packet: type 98 debug2: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug3: receive packet: type 99 debug2: channel_input_status_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug2: channel 0: rcvd adjust 2097152 debug3: receive packet: type 99 debug2: channel_input_status_confirm: type 99 id 0 debug2: shell request accepted on channel 0 Activate the web console with: systemctl enable --now cockpit.socket Edit 8 Switched out my home router (custom firmware) with ISP provided router. Still no joy. Edit 9 Wading into wireshark packet tracing. Success vs Fail: https://i.sstatic.net/fkL0z.jpg Graph: https://i.sstatic.net/SWrog.jpg Note: After raising my issue with my hosting provider (works for them) the OpenSSH server on the server has switched to OpenSSH 7.8 - but the issue persist. Edit 10 Wireshark. Client vs Server: https://i.sstatic.net/XRZRW.jpg Notes Frame 29 from server not received by client Hosting provider changed openssh back to v8
I have some good news. I raised an issue with my ISP. They've issued me with a new IP. I don't know what else they did but it has resolved the issue. I have also raised an issue with redhat developers working on openssh. They said this is a known issue especially in the VMWare community: https://communities.vmware.com/thread/590825 The issue is related to a change in OpenSSH_7.8 relating to the QoS flag. http://www.openssh.com/txt/release-7.8 The workaround is to use the following in your ~/.ssh/config file Host * IPQoS=throughput I will not mark this as the answer until I can confirm it working on my end.
Can't SSH into openssh server version 7.8 and greater
1,574,616,450,000
I'd like to, as the administrator of an OpenBSD ssh jumphost used by multiple people, run a specific command any time any user connects via SSH, even if just for tunneling. Is this possible? I've tried using ForceCommand and /etc/sshrc but these seem only to apply when the user has an interactive session and not otherwise. Because I'm running OpenBSD, nothing PAM-based will work unfortunately, i.e. This answer on Unix & Linux The script just runs sendmail using the whoami and $SSH_CONNECTION to inform me of who logged in and from where. #!/bin/sh [email protected] sendmail -F alerts -f $EMAIL root << EOF Subject: New Login For $1 Message-ID: <$(date +%s)@$(hostname)> X-Mailer: OpenSMTPD Content-Type: text/plain There has been a new login for $1 on $SSH_CONNECTION EOF
You can monitor /var/log/authlog and use awk to send you a message whenever a specific line matches: tail -f /var/log/authlog | awk '/Accepted pubkey/ { system("mail -s " $0 " [email protected] << EOF\nEOF") }' You can of course replace /Accepted pubkey/ with some other pattern that fits your case. I chose to send empty emails with the log line as a subject, for easier reading on the MUA, but you might prefer something like system("mail -s New\\ Login [email protected] << EOF\n" $0 "\nEOF")
Run command on SSH server whenever a user connects, even if just for tunneling
1,574,616,450,000
For my projects I have to customize the openssh code and I am planning to build the openssh-portable(https://github.com/openssh/openssh-portable) source code in the Alpine linux. But I am getting the following error while doing so. */home/openssh-portable # make (cd openbsd-compat && make) make[1]: Entering directory '/home/openssh-portable/openbsd-compat' cc -g -O2 -pipe -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE -I. -I.. -I. -I./.. -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -DHAVE_CONFIG_H -c arc4random.c In file included from /usr/include/fortify/sys/socket.h:25, from ../includes.h:27, from arc4random.c:27: **/usr/include/fortify/stdlib.h:40:1: error: 'realpath' undeclared here (not in a function); did you mean 'realloc'?** _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) ^~~~~~~~~~~ /usr/include/fortify/stdlib.h:41: confused by earlier errors, bailing out make[1]: *** [Makefile:99: arc4random.o] Error 1 make[1]: Leaving directory '/home/openssh-portable/openbsd-compat' make: *** [Makefile:165: openbsd-compat/libopenbsd-compat.a] Error 2* I suspect it is because the Alpine linux comes with the musl c librray rather than glibc library. I would like to know how to solve this error. Is it possible to install glibc in Alpine and configure the make command to use the glibc rather than musl c lib? Or should I cross compile the openssh-portable using musl C libarary? if so any guidance or steps will be appreciated? or is there any Alpine(i.e, musl C lib) compatible source code available which I can pull from a repo As specified in the environment, I am able to run autoreconf, ./configure and make commands successfully.
The issue seems to be with the fortify headers. I am able to build openssh-portable successfully on Alpine 3.8 without issues: Fresh alpine:3.8 image Installed build prerequisites: apk add autoconf gcc make musl-dev openssl-dev zlib-dev autoreconf && ./configure && make -j8 However, installing fortify-headers and reconfiguring causes the build to break with the above. Fortify has its own stdlib.h which makes use of __orig_realpath, which I suspect is a GNU extention. If fortify headers are not a strong requirement for your openssh build, try to omit them (apk del fortify-headers) and repeat the build.
Can I build openssh-portable source code in Alpine linux
1,574,616,450,000
The idea might be stupid or not feasible, I don't know, but I can't find any reference about this... As you may know (and as SE definitely knows!), one of the common steps used to tighten SSH security, provided file access is enough, is to lock the user in a chroot. OpenSSH has been providing such a chroot-based jail for years now. However that approach lacks flexibility (all-or-nothing, SFTP only, etc.) and it comes down to abusing a system call (which has security implications, hence the "the jail must be owned by root" and other recommendations rarely understood). Now that OpenSSH is provided as a sshd.socket and [email protected], I am tempted to use Linux namespace (which I get for free then) to restrain my users instead. I am just very surprise that I found literally nothing on that alternative scheme. So my question is, is there any reason not to use namespaces instead of chroot for that kind of usage?
You should try that and report back how it works. In everything, there is somebody first one! But my concern is that it would not work. The chroot from OpenSSH is called after all the key exchange, authentication and everything is done, but Systemd would force the namespaces even before starting the sshd process (if I understand its behavior correctly) and it might not be able to process the user authentication. Also in the service file, you are not able to differentiate users connecting so you would namespace all of them? How would you connect as a normal admin user to maintain this system? I believe it is certainly a good idea and useful for other services, but I don't believe you would be able to "abuse" it (for free) to suit your needs for OpenSSH.
Why do people still use SFTP jails based on SSH chroot rather than namespace capabilities of Systemd? [closed]
1,574,616,450,000
I have a problem when ssh to another server. I created ssh-key and copied it to other server. -bash-4.2$ whoami postgres -bash-4.2$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/var/lib/pgsql/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /var/lib/pgsql/.ssh/id_rsa. Your public key has been saved in /var/lib/pgsql/.ssh/id_rsa.pub. The key fingerprint is: 96:fd:e7:5b:d2:b0:ac:b3:3e:7b:55:fd:ad:4f:9f:c5 [email protected] The key's randomart image is: +--[ RSA 2048]----+ | | | | | .| | o o| | S . . +| | . . . =+| | . =oE| | o+o++| | .=*o+o| +-----------------+ -bash-4.2$ ssh-copy-id 192.168.2.75 The authenticity of host '192.168.2.75 (192.168.2.75)' can't be established. ECDSA key fingerprint is 20:00:96:92:ff:a7:00:cb:a1:3a:30:fe:db:dd:55:c6. Are you sure you want to continue connecting (yes/no)? yes /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys [email protected]'s password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '192.168.2.75'" and check to make sure that only the key(s) you wanted were added. But still asking password -bash-4.2$ ssh 192.168.2.75 [email protected]'s password: Last login: Thu Mar 31 10:09:45 2016 from 192.168.2.138 -bash-4.2$ whoami postgres -bash-4.2$ Hostname for connected: -bash-4.2$ hostname slave.localdomain.tld Hostname for connector: -bash-4.2$ hostname master.localdomain.tld But I can access to root user without password. -bash-4.2$ ssh-copy-id [email protected] /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys [email protected]'s password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '[email protected]'" and check to make sure that only the key(s) you wanted were added. -bash-4.2$ ssh [email protected] Last login: Thu Mar 31 10:10:20 2016 from 192.168.2.138 [root@slave ~]# Also I can access to remote server's postgres user without password -bash-4.2$ ssh-copy-id 108.61.199.64 -p 2222 /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys [email protected]'s password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh -p '2222' '108.61.199.64'" and check to make sure that only the key(s) you wanted were added. -bash-4.2$ ssh 108.61.199.64 -p 2222 Last login: Thu Mar 31 11:08:54 2016 from 78.189.14.197 -bash-4.2$ whoami postgres -bash-4.2$ hostname postgresql.MYDOMAIN.COM Here are the last lines of ssh -vvv output: debug2: we did not send a packet, disable method debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /var/lib/pgsql/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Trying private key: /var/lib/pgsql/.ssh/id_dsa debug3: no such identity: /var/lib/pgsql/.ssh/id_dsa: No such file or directory debug1: Trying private key: /var/lib/pgsql/.ssh/id_ecdsa debug3: no such identity: /var/lib/pgsql/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /var/lib/pgsql/.ssh/id_ed25519 debug3: no such identity: /var/lib/pgsql/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: ,password debug3: authmethod_is_enabled password debug1: Next authentication method: password Can anyone help me what did I wrong? Edit: Here are the permissions of root&postgres users. [root@localhost pgsql]# ll /var/lib/pgsql/ total 12 dr-xr-x---. 4 postgres postgres 67 Mar 31 09:57 . drwxr-xr-x. 27 root root 4096 Mar 31 13:15 .. -rw-------. 1 postgres postgres 1350 Mar 31 13:02 .bash_history -rwx------. 1 postgres postgres 268 Mar 30 14:15 .bash_profile drwx------. 2 postgres postgres 76 Mar 31 10:46 .ssh drwx------. 4 postgres postgres 48 Mar 31 09:30 9.5 [root@localhost pgsql]# ll /root/ total 32 dr-xr-x---. 4 root root 4096 Mar 31 09:31 . dr-xr-xr-x. 17 root root 4096 Mar 31 09:37 .. -rw-------. 1 root root 3389 Mar 31 10:59 .bash_history -rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout -rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile -rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc -rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc drwxr-----. 3 root root 18 Mar 30 14:14 .pki drwx------. 2 root root 76 Mar 31 12:51 .ssh -rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc Here is the /var/log/audit/audit.log when I want to ssh. [root@localhost pgsql]# cat /var/log/audit/audit.log type=CRYPTO_KEY_USER msg=audit(1459431065.262:1195): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=2b:3f:aa:b8:46:1d:b8:f9:d7:c2:16:96:67:68:f1:0d direction=? spid=3585 suid=74 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_KEY_USER msg=audit(1459431065.262:1196): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=session fp=? direction=both spid=3585 suid=74 rport=56439 laddr=192.168.2.75 lport=22 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=USER_ERR msg=audit(1459431065.263:1197): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=PAM:bad_ident grantors=? acct="?" exe="/usr/sbin/sshd" hostname=192.168.2.138 addr=192.168.2.138 terminal=ssh res=failed' type=CRYPTO_KEY_USER msg=audit(1459431065.264:1198): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=ef:0b:31:91:b7:38:45:42:88:6d:d5:d7:c2:f7:ee:6a direction=? spid=3584 suid=0 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_KEY_USER msg=audit(1459431065.265:1199): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=20:00:96:92:ff:a7:00:cb:a1:3a:30:fe:db:dd:55:c6 direction=? spid=3584 suid=0 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_KEY_USER msg=audit(1459431065.265:1200): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=2b:3f:aa:b8:46:1d:b8:f9:d7:c2:16:96:67:68:f1:0d direction=? spid=3584 suid=0 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=USER_LOGIN msg=audit(1459431065.265:1201): pid=3584 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=login acct="postgres" exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=ssh res=failed' type=CRYPTO_KEY_USER msg=audit(1459431066.776:1202): pid=3589 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=ef:0b:31:91:b7:38:45:42:88:6d:d5:d7:c2:f7:ee:6a direction=? spid=3589 suid=0 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_KEY_USER msg=audit(1459431066.776:1203): pid=3589 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=20:00:96:92:ff:a7:00:cb:a1:3a:30:fe:db:dd:55:c6 direction=? spid=3589 suid=0 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_KEY_USER msg=audit(1459431066.776:1204): pid=3589 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=destroy kind=server fp=2b:3f:aa:b8:46:1d:b8:f9:d7:c2:16:96:67:68:f1:0d direction=? spid=3589 suid=0 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_SESSION msg=audit(1459431066.777:1205): pid=3588 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=start direction=from-server cipher=aes128-ctr ksize=128 [email protected] [email protected] spid=3589 suid=74 rport=56440 laddr=192.168.2.75 lport=22 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=CRYPTO_SESSION msg=audit(1459431066.777:1206): pid=3588 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=start direction=from-client cipher=aes128-ctr ksize=128 [email protected] [email protected] spid=3589 suid=74 rport=56440 laddr=192.168.2.75 lport=22 exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=? res=success' type=AVC msg=audit(1459431066.945:1207): avc: denied { read } for pid=3588 comm="sshd" name="authorized_keys" dev="dm-0" ino=47671 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:postgresql_db_t:s0 tclass=file type=SYSCALL msg=audit(1459431066.945:1207): arch=c000003e syscall=2 success=no exit=-13 a0=7f1e85e81ac0 a1=800 a2=1 a3=7f1e7fa5e2e0 items=0 ppid=3551 pid=3588 auid=4294967295 uid=0 gid=0 euid=26 suid=0 fsuid=26 egid=26 sgid=0 fsgid=26 tty=(none) ses=4294967295 comm="sshd" exe="/usr/sbin/sshd" subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 key=(null) type=USER_AUTH msg=audit(1459431066.945:1208): pid=3588 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=pubkey acct="postgres" exe="/usr/sbin/sshd" hostname=? addr=192.168.2.138 terminal=ssh res=failed' Note: All three servers are running Centos 7 Local Server: CentOS Linux release 7.1.1503 (Core) Remote Server: CentOS Linux release 7.2.1511 (Core)
I found solution at https://serverfault.com/questions/321534/public-key-authentication-fails-only-when-sshd-is-daemon restorecon -r -vv /var/lib/pgsql/.ssh command was enough. I think problem occured because of SELinux. Here is the restorecon command manual. http://linux.die.net/man/8/restorecon
SSH access asking for password in local network but public
1,574,616,450,000
I need restrict session limit on my OpenSSH server only for one session (one connection). I use Ubuntu Desktop 7.10. Of course Version is old, but I need it for experimental purposes. I tried modify my config file - /etc/ssh/sshd_config two ways: First I changed: MaxStartups 1 but it does not work correctly. I can make many connections still. Second I changed: MaxSessions 1 after restart I get error message: /etc/ssh/sshd_config: line 71: Bad configuration option: MaxSessions /etc/ssh/sshd_config: terminating, 1 bad configuration options I saw to sshd_config MaxSessions parameter and I tried add: mato - maxlogins 1 to /etc/security/limits.conf but it does not work. I used - http://www.cyberciti.biz/faq/iptables-connection-limits-howto/ too: /sbin/iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 1 -j REJECT, but I get error message: iptables: No chain/target/match by that name
http://www.openssh.com/txt/release-5.1 The MaxSessions option was implemented on the version 5.1 of OpenSSH. Ubuntu 7.10 uses the version 4.6 so, this option will not be available to you. http://www.ubuntu.com/usn/usn-612-2/ Possible solutions: Download a newer version of OpenSSH and comple it Make a "apt-pinning" and install a newer version of it What about if you put the following option on your limits.conf? user hard maxlogins 1 Since your ar using a pretty old piece of software, a lot of OpenSSH options and iptables modules could not be available to help you on this task
Session limit for OpenSSH server on Ubuntu Desktop 7.10
1,574,616,450,000
I know I can add the following entry: PubkeyAcceptedKeyTypes=+ssh-dss to ~/.ssh/config as described here but I need to do so for each entry. I want to enable it globally. Is it possible ?
To enable it for all connections you personally make (rather than for all users on the system), just put it in your ~/.ssh/config one time: Host * PubkeyAcceptedKeyTypes=+ssh-dss This will apply to all hosts unless overridden with a different PubkeyAcceptedKeyTypes setting in a subsequent specific Host clause. From man ssh_config: A single ‘*’ as a pattern can be used to provide global defaults for all hosts.
Globally enable ssh-dss on openssh 7.0
1,574,616,450,000
i have some problems with the ssh proxycommand. The authentication on the proxy works fine, but when i want to login to the remote-host it fails. The problem seems to be, that the proxy tries to login with my local rsa_key and not with the key stored on the proxy. Is there a way to fix this? This is what i want: Local -- local rsa --> Proxy -- proxy rsa --> host The Config-file i use: Host 192.168.178.32 HostName 192.168.178.32 User user Port 22 IdentityFile ~/.ssh/id_rsa.pub Host 192.168.178.30 HostName 192.168.178.30 User user Port 22 IdentityFile home/user/.ssh/id_rsa.pub ProxyCommand ssh -W %h:%p -F ssh_config -p 22 192.168.178
This probably isn't the answer you want to hear, but you can't do what you're trying to do. The ProxyCommand option in ssh expects to STDIN & STDOUT of the command to be connected directly to the destination host (%h) and port (%p). Thus it is the local ssh process which is talking to the remote sshd, not the proxy host's ssh process. And since it's the local ssh process talking to the remote, it doesn't have access to any ssh keys sitting on the proxy. Ultimately you only have 2 options: Copy the ssh key off the proxy host and install it locally. Set up a local command which transparently executes ssh on the proxy. For example: alias sshp='ssh -t 1.2.3.4 ssh'
Problems with SSH ProxyCommand [closed]
1,574,616,450,000
I have ssh keypair on my ansible_host, which I want to copy to multiple user's authorized keys on target host. I'm trying with-item construct, but it complaints about .pub key not an invalid key here's what I'm trying. - authorized_key: user: "{{ item.user }}" key: "{{ item.key }}" with_items: - { user: "user1", key: "~/.ssh/id_rsa.pub" } - { user: "user2", key: "~/.ssh/id_rsa.pub" } ERROR: "msg": "invalid key specified: ~/.ssh/id_rsa.pub"}
If you only need to copy your key to multiple users you can do it like that : - authorized_key: user: "{{ item.user }}" key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}" with_items: - { user: "user1" } - { user: "user2" }
ansible copy ssh keys to multiple users' home directory
1,574,616,450,000
I have never seen this before in my sshd logs: Mar 16 17:21:48 x-server sshd[9848]: Bad protocol version identification '\026\003\001' from 45.143.221.50 port 35026 Mar 16 17:21:48 x-server sshd[9849]: Bad protocol version identification '\026\003\001' from 45.143.221.50 port 35254 Mar 16 17:21:48 x-server sshd[9850]: Bad protocol version identification 'GET / HTTP/1.1' from 45.143.221.50 port 35384 Mar 16 17:21:48 x-server sshd[9851]: Bad protocol version identification 'GET /vtigercrm/vtigerservice.php HTTP/1.1' from 45.143.221.50 port 35608 Mar 16 17:21:48 x-server sshd[9852]: Bad protocol version identification '\026\003\001' from 45.143.221.50 port 35810 Mar 16 17:21:48 x-server sshd[9853]: Bad protocol version identification 'GET /a2billing/admin/Public/index.php HTTP/1.1' from 45.143.221.50 port 36000 Mar 16 20:57:24 x-server sshd[10424]: Bad protocol version identification 'GET / HTTP/1.1' from 18.206.190.72 port 43800 This attack seems to send http requests through an SSH connection initiation while no webserver is running on this machine and no PHP is installed. It is also a mystery to me how the ports have been mapped to sshd in these cases since this sshd is behind a NAT and is not directly connected to the internet. How can I mitigate such an attack?
I have no idea about how it got past a NAT. But I will answer the rest. A port is not a protocol: While ssh is usually on port 22, and http on port 80. This is only so we can find them easily. There is nothing fixed about these protocols and ports. What seems to have happened is a web-browser (or web-spider) has tried to connect to port 22 (maybe it is trying all the ports). You ssh-server is completely safe from this. It is an example of a client not authenticating properly. Just ensure that your logs are rotated, so they don't fill-up your drive. There is no ssh connection. The ssh connection is not yet up, the connection is still at the level of TCP/IP. The request coming from the remote, is independent of the software installed on your machine. For example, when someone connects to a web-site they do not, first, check to see what software is installed on the server.
What kind of an sshd attack is this?
1,574,616,450,000
When I connect to a remote machine using ssh, my ssh agent will try all key files available in .ssh. Per default, how many key files can the agent try for the log-in until server sends permission denied (publickey)?
From man sshd_config: MaxAuthTries Specifies the maximum number of authentication attempts permitted per connection. Once the number of failures reaches half this value, additional failures are logged. The default is 6. My memory is that this has been consistent for many releases of OpenSSH, but as with any configurable, it is best to run man on your own system (the remote system in this case) to check the manual pages for the actual installation on that system.
What is the default number of login attempts before login fail
1,574,616,450,000
Background: I have openSUSE Tumbleweed running on a local server (an old re-purposed HP desktop) and I am going to install LAMP and wordpress on it. I want to administrate the server remotely so I do not have to have a workstation set up for it. I also want to try out some penetration testing on the server, and I have a perfect little Toshiba Portege 830 COREi5 with Kali installed on it so that I can search for vulnerabilities in my server. I figure it will be like playing chess against myself. Ideally I would like to use the same Portege to administrate the server - however this is where I ran into difficulties connecting from the client to the server, so i tried running recommended debugging commands I have seen on many websites (for example: http://www.snailbook.com/faq/general-debugging.auto.html). SSH suffix commands do not even seem to be acknowledged by the Kali terminal. I run the same and other commands in openssh-server installed on the openSUSE server, but no commands are recognized by the openssh-client installed on the Kali notebook. All of the following: root@kali:~# ssh -v -p 222 root@kali:~# ssh -p 222 root@kali:~# ssh return only a usage printout: usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command] The ssh server is running: root@kali:~# service ssh status ● sshd.service - OpenSSH Daemon Loaded: loaded (/lib/systemd/system/ssh.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2017-05-01 03:45:55 BST; 24min ago Main PID: 7637 (sshd) Tasks: 1 (limit: 4915) CGroup: /system.slice/ssh.service └─7637 /usr/sbin/sshd -D Why are these commands not working?
ssh -v -p 222 and ssh -p 222 should return an error on their own. You need to specify a host to connect to, either by ip or by hostname (either qualified DNS name or something specified in /etc/hosts). For example, by IP: ssh -v -p 222 192.168.0.3 You need to use the IP address of the openSUSE server.
ssh -v -p 222 and other ssh suffix comands are not recognized in terminal
1,574,616,450,000
I have a directory full of ssh private keys, and I'd like to check what keys are accepted on what server without logging in. How can I do that without adding the ssh-keys to my authentication client with ssh-add or logging in on the server? How does ssh know what keys it should try to authenticate with? Does the server send the fingerprints of the keys it can use or does the client send all it's fingerprints and the server then checks them?
You can use something like: #!/bin/bash KEYPATH=~/.ssh/* HOSTS=( localhost hosta hostb ) probekey () { for privkey in $KEYPATH do if [[ "$(file $privkey)" =~ "private" ]] then #echo "Probing key $privkey for host $1" ssh -i "${privkey}" -o "IdentitiesOnly yes" -o "PreferredAuthentications publickey" -o "ControlMaster no" "$1" exit 2>/dev/null if [ "$?" == "0" ] then echo "Key ${privkey} matches for host $1" fi fi done } for HOST in ${HOSTS[@]} do probekey $HOST done What this script basically does is iterating through an array of hosts ($HOSTS) and performs the probekey function. The function iterates through the list of files in $KEYPATH, checks if the file type contains private (for RSA or DSA private key files) and if that matches it starts a ssh connection to the host using that particular key. If the connection was succesfull the returncode is 0 and a message is printed. This is not an exact answer to the question because it does login to the host (when a key matches) and performs the exit command to directly logout again.
Check what ssh keys are accepted on server
1,574,616,450,000
I set up a new server (hostname: odroid) and copied my public ed25519 key to it. I signed to it for the first time and noticed 3 new entires have been added to ~/.ssh/known_hosts on my local machine: odroid ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDnb0Xd02liZf5KJLuvmaQ/6Yo3Jsr4g427ly8AzmhjI odroid ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4ZPifCej2M/lZofl12auXhXUWzoNwWvOBjLntmR0sWwlF9xnb/NAq8qoyUctYUFEo2llrs/B2uvg5nKyQFTFYzJtTsNMlYvn4Bf/xLuPe8I7ZB1TgTKWru9mwpBOPifahIxiK0X2gtkAkzdRlTKW532dNltI+2naF2RKRYYa8fAV1FNxhAQOTb5u3WHXVW2WG1GZIPLxqObqO33egf4nt74ir1aWUUU4/YRMYUYc28xdHbpKu4QXrvuHGsY4J7VDRA5msMEXGsbIcb4m99xmxYj2n9v7D/soeEpOB1JKA/VKrXK5vSvzujMuzCaOJr/PbJUP7eKAthCQdXubAtj9h8DLLOWmz76nHeH23p4Fdqjp3B0kgCtzwVNr0SAdOnGWMEBq2bHOkjuYfQHgJJBrTe5dc19WyJQIehC4fpqX2PE/JVvv4a/km2CiFNdDPybHaZvFWtAMRyrSsP844+oLsMrQUAlQX5WnYCf7iHj2ujR0VOD0NMdwzaILsaAxvrAU= odroid ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPRjuYovCQ1dLKryILWs2YikUrtVGXNZMa6wMBSUd1JpLGQAo/KxE0Ib3nNEk43iWOB73e9cPWz0AdMeBTI1G8c= Why is that? Can I force my ssh client to only insert the entry for ssh-ed25519 and not for ssh-rsa and ecdsa-sha2-nistp256?
Those are the server's host keys, by which your SSH client verifies that future connections aren't to some other server trying to impersonate this one. They have nothing to do with which key is used to authenticate your user to that server, or even whether you use a key at all. While it may be possible to force your client to save only one type of key, there's no good reason to do so. In fact, saving keys of multiple types allows the server to rotate the key of any given type by updating and keeping the other unchanged, and this makes life easier for the people managing that server.
Why are 3 entries added to ~/.ssh/known_hosts even though I use only a single key type?
1,574,616,450,000
In this example: $ ssh -L 8001:192.168.122.4:80 the output give is the default help: usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] destination [command] What could be the reason(s)?
The command is incomplete. As you can see in the usage page, the only mandatory argument is destination and you have not specified it. -L 8001:192.168.122.4:80 is a parameter but it is not the destination. Each ssh connection is independent, you really need to provide, for each one, at the very least, a destination. That's why you get the usage information. Try something like this: $ ssh -L 8001:192.168.122.4:80 destination
Why does ssh port forwarding fail?
1,574,616,450,000
A newer server admin tried to set me up to authenticate SSH using a public key. It wasn't configured correctly, and SSH kept asking me for password (and he kept telling me to hit enter). Unexpectedly, I am no longer able to connect to the server at all on any port. (It is a public web server.) I spoke to the more senior Sysadmin and he couldn't figure out what happened. It feels very much like some service similar to fail2ban blocked the ip, but the sysadmin is sure it isn't on the server. (I also double checked systemctl and etc, and I don't see it.) Also there is no rule in iptables blocking my IP. Where are other places to look for something blocking the IP? (I've also checked /var/log but don't see any obvious log files that show the block.) Note: the server is in a Digital Ocean data center. I ran tracert, and the last IP it reported before timing out was 138.197.244.33 (which looks like a Digital Ocean front door).
After doing a lot of detective work and finally checking the list of running services more carefully: systemctl list-units --type=service --all | grep running I found that lfd.service (ConfigServer Firewall & Security - lfd) was running (not being a Linux sysadmin, I didn't know anything about it), and this turned out to be the culprit. The lfd.service does indeed monitor authentication failures and then blacklists IPs in /etc/csf/csf.deny. To remove the IP from the blacklist use: csf -dr <the IP> Here is a helpful guide to CSF.
After SSH authentication failures (Centos 7) something blocked my IP
1,574,616,450,000
I've recently installed Kali linux on my Raspberry Pi 4, and I'm running into a problem that i can only ssh in after I log in to the kali user's desktop. This is an issue as I intend to run this headless most of the time. Edit: To be more specific, before logging in, I get No route to host when trying to SSH into the device. As soon as I log into the desktop, I can connect successfully. Edit 2: After checking journalctl -u ssh, I have found that SSH actually does start on boot, but I can only connect after logging in. I've have enabled the ssh service using sudo systemctl enable ssh and sudo systemctl enable ssh.service, and I'm not really sure what else to do. If anyone could provide some insight towards what could be causing this, it would be greatly appreciated
A no route to host error message means the network interface is not up and running yet. Have you perhaps saved your network configuration as per-user settings? If so, then NetworkManager won't have access to that network configuration until you log in, and so cannot set up the network interface. If you configure the network interface using a graphical user interface, there is usually a checkbox for "every user can use these settings", or something similar. If you check it, that network configuration will be saved as system-wide configuration, and will be usable whether or not you're logged in, allowing NetworkManager to complete network set-up during boot. But if you don't tick that box, that network configuration will be available for your user account only, requiring you to log in locally first. This is intended mostly for making certain WiFi or VPN connections private: for example, user kiddy might only have access to an adult-content-filtered, bedtime-restricted WiFi network at home, but user daddy might also have access to a different, unrestricted "man-cave" WiFi network plus a work VPN connection. But I think the default setting when making a new network configuration is "per-user", which may come as a surprise when configuring a basic wired network connection. If you have the settings in the form of a .nmconnection file, two steps are needed to make that connection usable system-wide without requiring any specific user to login: if the connection file has a permissions= line, delete that line completely. move the connection file to /etc/NetworkManager/system-connections/ directory, if it isn't already there.
SSH only starting after logging in to user in kali linux
1,625,864,176,000
I have an Ubuntu 16.04.7 LTS where I get the following response upon dpkg-query: dpkg-query -l 'openssh*' Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==========================================-==========================-==========================-========================================================================================== ii openssh-client 1:7.2p2-4ubuntu2.10 amd64 secure shell (SSH) client, for secure access to remote machines ii openssh-server 1:7.2p2-4ubuntu2.10 amd64 secure shell (SSH) server, for secure access from remote machines ii openssh-sftp-server 1:7.2p2-4ubuntu2.10 amd64 secure shell (SSH) sftp server module, for SFTP access from remote machines Looks like I do have openssh-server installed but I still don't see /etc/ssh/sshd_config file. Does Ubuntu do things differently?
This file gets installed when you install the openssh-server package (it's part of the postinst script). Try running: sudo apt-get install --reinstall openssh-server
Unbuntu 16 does not have sshd_config
1,625,864,176,000
Specifically, I have installed OpenSSH on both machines: GNU/Linux Debian 9.3 with OpenSSH version 1:7.4p1-10+deb9u2 Linux Mint 18.3 with OpenSSH version 1:7.2p2-4ubuntu2.4 In this question, I read the following file is distributed with OpenSSH source code: /etc/ssh/moduli Presumably with the package(s). Am I right with assumption, that if I change the file in order to get the weak sizes out, and if I don't hold the openssh-server and / or openssh-client package(s), the file will be overwritten by the their next version update? And if it will, can I put the single file on hold somehow? I did the following: Backed the file up: mv /etc/ssh/moduli /etc/ssh/moduli.bak Filtered out the sizes less than 4095 with: awk '$5 >= 4095' /etc/ssh/moduli.bak > /etc/ssh/moduli
That depends on your operation system. Debian-like systems ("like" Ubuntu) will most certainly ask you what to do with the file: Configuration file `/etc/ssh/moduli' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. *** moduli (Y/I/N/O/D/Z) [default=N] ?
Shall I hold the openssh packages after modifying /etc/ssh/moduli?
1,625,864,176,000
The process of getting Putty communicating with OpenSSH has thwarted me for quite some time. I installed OpenSSH with: sudo apt-get install openssh Then I generated ssh keys with: ssh-keygen -t rsa -b 4096 -C "my user here" The above command moved the public and private key combo to my user's profile home .ssh directory (/home/myUser/.ssh) (I think I may have had to create the .ssh folder there in order for ssh-keygen to work properly) Then I copied the private key to Windows and tried to use it in Putty. The server kept denying me.
I installed OpenSSH with: sudo apt-get install openssh The ssh server is in openssh-server package. SO either you do not have server installed and you are not connecting to your server or it was installed before. The above command moved the public and private key combo to my user's profile home .ssh directory (/home/myUser/.ssh) (I think I may have had to create the .ssh folder there in order for ssh-keygen to work properly) It generated your keys on server. But to have the keys "authorized", you need to copy the id_rsa.pub to ~/.ssh/authorized_keys`. Then I copied the private key to Windows and tried to use it in Putty. The server kept denying me. PuTTY does not understand the private key in OpenSSH format. You need to convert it to PuTTY format, using PuTTYgen. Also, it is considered bad practice to move private keys around. As you are using PuTTYgen anyways, you can generate the keys on the client machine and copy just the public key to the server (apparently you still have to convert it to openssh format there: https://stackoverflow.com/a/10015651/15359441).
How do I communicate with OpenSSH on Linux from Putty on Windows?
1,625,864,176,000
My problem is similar as the one described here. I've three hosts A, B and C. A is the computer I get at home. B is a server that we have at the University which is connected to the Internet. C is a computer in the Office of the University. Connected in the same local network with the server. So I can SSH from A -> B and from B -> C, but not from A -> C. I want a direct connection from A to C. There is a great solution described here. But my problem is that the solution is applied on A host and I preferred a solution that I can put up on host B because I want to make it easy for other users who desire the same connection. I note here that most users are teachers who do not have computer skills. Any help please.
First, here's better solution than the one given in the link provided in the question, since this new one has no dependencies on external tools like netcat: Host C ProxyCommand ssh -W %h:%p B in the .ssh/config of host A. Users don't need to have specific computer skills, they just need to be informed. Anyone can put 2 lines in a file. If this is really a problem, a specific command could be added to the .ssh/authorized_keys file on host B: command="ssh C" ssh-rsa <key_of_the_user_of_host_A> So, when the user does ssh B, instead of starting an interactive shell on host B, the SSH server on host B will automatically run ssh C (see the sshd(8) man page). However this will prevent any direct logging on host B, and any other SSH command, such as /bin/bash -l in ssh -t B /bin/bash -l, will be ignored. As the man page says: The command originally supplied by the client is available in the SSH_ORIGINAL_COMMAND environment variable. So, there may be some room for improvement, either to run the supplied command on host C, or to run it on host B under some conditions (also be careful with quoting if you take this environment variable into account). One example is: command="ssh ${TTY:+-t} C ${SSH_ORIGINAL_COMMAND-$SHELL}" ssh-rsa <key> which runs the supplied command on host C if there is one (and will start an interactive shell as usual if there isn't). With this, scp may work, but on my machine it fails with "Permission denied" errors. But rsync works well and can be used as a replacement for scp if you have problems with it. Important. Do not choose a solution that consists in opening a (necessarily non-privileged) port on host B. Either this will not work because connections to such ports are blocked by the firewall of the University, or this will introduce security issues as this will allow users to bypass authentication (with things like tracing) on host B via the SSH server on port 22.
Implement SSH redirection on a remote host
1,625,864,176,000
My goal is to build a LAMP server on my arch linux laptop. The main reason is for a web server. The other reason is to learn about how all this administration stuff works. My setup is a laptop with Arch Linux. I deleted windows and am using only linux. I have one added user other than root. My big question: Is it a good idea to make a new user and that user be the server?
One way of thinking of users are actual accounts which a person could log into on your server. But a more common view of users, which you should get used to for administration, is more like a system role. For example, if you install apache, you will see apache running as 'http' or 'apache' user. That is a legit user on your system, but noone could login as 'http' or 'apache'. Users should not be thought of as a scary thing. It is okay to have a lot of different users on your system. The real keys to the kingdom are in the root access and the ability to use sudo to access other user accounts. As long as you keep root locked down and secure, and don't give anyone else sudo access, you can have a lot of users and stay safe. Just remember files execute as the user who owns that file. So if you have a script in a file owned by root, that script could be very powerful because the commands it runs are carried out as if root were invoking those commands. The file inherits the same privileges, but also the same restrictions, as are held by the user which owns the file. This is why apache runs as 'apache'. In a way, it protects the rest of the server if 'apache' user ever got compromised. That is just an example, but the general principle applies to the big picture.
Setting Up SSH. Just need some understanding
1,625,864,176,000
I have a zsh script with which I logged into a remote host to copy some folders. The system asks me each time to give the password of the local host which I want to bypass, otherwise I have to enter the passphrase many times. I followed the following tutorial: https://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/ It worked once but then it didn't work. I followed the following steps (and followed them many times again) but now it does not work anymore. [local-host]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):<Hit enter> Enter passphrase (empty for no passphrase): <Enter your passphrase here> Enter same passphrase again:<Enter your passphrase again> Your identification has been saved in /home/jsmith/.ssh/id_rsa. Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub. The key fingerprint is: 31:3a:5d:dc:bc:81:81:71:be:31:2b:11:b8:e8:39:a0 jsmith@local-host I then copied the content of the public key from the local-host and pasted it to /home/jsmith/.ssh/authorized_keys on the remote-host and ran: [remote-host]$ chmod 755 ~/.ssh [remote-host]$ chmod 644 ~/.ssh/authorized_keys But then if I tried to log again, [local-host]$ ssh jsmith remote-host But instead of having the following message: Enter passphrase for key '/home/jsmith/.ssh/id_rsa': <Enter your passphrase here> Last login: Sat Jun 07 2008 23:03:04 -0700 from 192.168.1.102 No mail. I get this: jsmith remote-host's password: What am I doing wrong? EDIT Many thanks for the answer and the comments which I'll try to adress point per point: regarding the -l, I indeed did not use but instead I used ssh jsmith@remote-host I run the following with the following output [local-host]$ eval $(ssh-agent -s) Agent pid 96546 [local-host]$ env | grep SSH SSH_AUTH_SOCK=/var/folders/jq/yyp9q2fs1z5780k9l1_2ph4r0000gn/T//ssh-9ew9mjQCJWFK/agent.96545 SSH_AGENT_PID=96546 EDIT 2 So then I tried the following [local-host]$ ssh-add .ssh/id_rsa Enter passphrase for .ssh/id_rsa: Bad passphrase, try again for .ssh/id_rsa: EDIT3 Ok so the whole permission tree on the remote machine and local machine is the following: /var/services/homes/user01/.ssh/ the permissions of each branch are the following (with ls -ld <directory> and ls -la <file> command (from bottom up): For the remote machine: drwxr-xr-x 1 user01 users 0 Oct 3 16:44 .ssh drwxrwxrwx+ 1 user01 users 90 Oct lrwxrwxrwx 1 root root 14 Oct 4 09:07 homes -> /volume1/homes drwxr-xr-x 2 root root 4096 Oct 4 09:07 services drwxr-xr-x 15 root root 4096 Oct 4 09:07 var For the local machine: drwx------ 7 user02 staff 224B Oct 4 09:27 .ssh/ drwxr-xr-x+ 152 user02 staff 4.8K Oct 4 09:27 user02/ drwxr-xr-x 6 root admin 192B Jan 1 2020 /Users/ Do you have an idea about what I should do next? Many thanks in advance
You need to run the local ssh-agent. And in the "I tried to log again" you forgot the -l (or, alternatively, jsmith@remote-host). There's a good chance that you did start the agent and did the ssh-add part, too, but in a different session. What I do is to invoke eval $(ssh-agent -s) from my window-managers initialisation, that way any shell will know about the agent ... $ env | grep SSH SSH_AUTH_SOCK=/tmp/ssh-LxwUgd8tuGU3/agent.1023801 SSH_AGENT_PID=1023802 On top of everything else, a chmod 750 $HOME and chmod 700 $HOME\.ssh are important too, though the initially described messages didn't hint at those.
Log in to remote server by using a generated public key
1,625,864,176,000
I am exploring methods to correlate my current SSH session with the SSHD logs. I aim to extract specific information from the SSHD logs that pertain to my SSH session only. Jul 04 09:39:06 linuxbox sshd[1122]: Accepted publickey for testuser from 1.2.3.4 port 123 ssh2: RSA-CERT ID test (serial 1) CA RSA fingerprint... One option was to map the sshd pid logged during ssh login sshd[1122] to the current ssh session pid. But I could not find a way to get current ssh session pid. Or Is there any other way to map my session to the sshd logs apart from matching PID? testuser@linuxbox:~$ testuser@linuxbox:~$ sudo systemctl status sshd * ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2023-07-04 09:10:20 UTC; 29min ago Docs: man:sshd(8) man:sshd_config(5) Process: 1023 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 1024 (sshd) Tasks: 1 (limit: 1109) Memory: 2.7M CGroup: /system.slice/ssh.service `-1024 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups Jul 04 09:39:03 linuxbox sshd[1122]: rexec line 126: Deprecated option UsePrivilegeSeparation Jul 04 09:39:06 linuxbox sshd[1122]: Accepted publickey for testuser from 1.2.3.4 port 123 ssh2: RSA-CERT ID test (serial 1) CA RSA fingerprint... Jul 04 09:39:06 linuxbox sshd[1122]: pam_unix(sshd:session): session opened for user testuser by (uid=0) testuser@linuxbox:~$ date Tue 04 Jul 2023 09:39:50 AM UTC testuser@linuxbox:~$ ps -ef | grep sshd root 881 1 0 09:05 ? 00:00:00 sshd: testuser [priv] root 884 1 0 09:05 ? 00:00:00 sshd: testuser [priv] testuser 893 881 0 09:05 ? 00:00:00 sshd: testuser@pts/0 testuser 904 884 0 09:05 ? 00:00:00 sshd: testuser@notty root 1024 1 0 09:10 ? 00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups root 1122 1024 0 09:39 ? 00:00:00 sshd: testuser [priv] testuser 1124 1122 0 09:39 ? 00:00:00 sshd: testuser@pts/1 testuser 1151 1125 0 09:39 pts/1 00:00:00 grep --color=auto sshd testuser@linuxbox:~$
To get the PID of your current session, you can use pstree with the -s flag ("show parents of the selected process"). $ pstree -sp $$ systemd(1)───sshd(1583)───sshd(30575)───sshd(30577)───tcsh(30579)───pstree(30915) The relevant PID of your session is the child of the main PID sshd process, which you can find using: $ systemctl show -p MainPID sshd MainPID=1583 So the PID of your session is 30575. And once you have the PID of your current session, you can use journalctl: journalctl -u sshd _PID=30575
How can I map the sshd logs to my current ssh session?
1,625,864,176,000
At first, I'd like to note that I am aware that there are a lot of other questions regarding SSH agent forwarding. The people there wanted to know how to make agent forwarding work or how to configure it securely. But I have the opposite problem: It seems that I can't reliably disable it. So here we go: I am running a Debian bullseye system, up to date at the time of writing, basically vanilla. On that system, a SSH daemon is running, with the following configuration in /etc/ssh/sshd_config: AcceptEnv LANG LC_* AllowAgentForwarding no AllowTcpForwarding no AllowStreamLocalForwarding no ChallengeResponseAuthentication no Ciphers [email protected],[email protected] Compression no DebianBanner no HostKeyAlgorithms rsa-sha2-512,ssh-ed25519 KbdInteractiveAuthentication no KexAlgorithms curve25519-sha256,[email protected],diffie-hellman-group-exchange-sha256 ListenAddress aaa.bbb.ccc.ddd LoginGraceTime 20 MACs [email protected],[email protected] PasswordAuthentication no PermitUserRC no Protocol 2 # The first of the following version is the right one. # However, for brain-dead WinSCP, we need the second version. #PubkeyAcceptedKeyTypes rsa-sha2-512,rsa-sha2-256,ssh-ed25519 PubkeyAcceptedKeyTypes rsa-sha2-512,rsa-sha2-256,ssh-ed25519,ssh-rsa RekeyLimit 100M 20m Subsystem sftp /usr/lib/openssh/sftp-server Match user copyremote ChrootDirectory /backup ForceCommand /usr/lib/openssh/sftp-server This is the complete configuration file; nothing has been removed or obfuscated except the IP address it listens on. Furthermore, there are no other places that contain additional configuration snippets for the SSH daemon. Basically, that configuration tries to turn off every feature I don't need, for example the agent forwarding feature (note: In that configuration file, I didn't add the lines for most of the features that are off by default (according to the manual)). We also see that the authentication is based on public keys exclusively. The other day I was investigating a problem with the user copyremote and the sftp subsystem and therefore gave -v as parameter to sftp on a client machine. That lead to the following output (showing only relevant portions): root@morn ~/scripts # sftp -v -i ~/.ssh/id_rsa_backup_user [email protected]:/backup/achilles.bsdtar.gz . OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022 [...] debug1: Remote: /home/usr/copyremote/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding debug1: Remote: /home/usr/copyremote/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding [...] Now that's frightening. I thought I had turned off agent forwarding globally in the system-wide configuration file on the server. However, as I understand that output, it offers it. Could anybody please explain how I can turn off agent forwarding (and further features that I don't want the server to offer) globally? Those features can be explicitly disabled in the authorized_keys files, but that would be very error prone and a lot of work if there are multiple users and each of them accepts multiple public keys, so I'd really prefer being able to turn it off at one place. This is the authorized_keys file of the user copyremote on the server: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDs6ku+LXaUBs....JFchhaoQ== me@client There is nothing special in there. Notably, agent forwarding is not allowed explicitly. Why does it not apply the setting from the system-wide configuration then? P.S. I am aware that SSH / SFTP chroot does not provide the security we would expect from it. I have implemented further measures on the server that mitigate that problem, so it doesn't need to be discussed here :-)
It only says that the agent forwarding would be possible with the key (default), had the agent forwarding been enabled globally (what it is not). The log entry shows only result of parsing the authorized_keys file. It basically says that no-agent-forwarding flag was NOT found at the respective entry. It in no way reflects the AllowAgentForwarding no directive.
Meaning of "key options: agent-forwarding" in OpenSSH logging
1,625,864,176,000
I have a system user syncoid as $ cat /etc/passwd syncoid:x:993:990::/var/lib/syncoid:/run/current-system/sw/bin/nologin with the following ssh config: $ cat /var/lib/syncoid/.ssh/config Host eve User other HostName 192.168.10.1 ProxyJump jumphost IdentityFile /var/lib/syncoid/.ssh/eve-syncoid Host jumphost ForwardAgent yes User me HostName 192.168.1.1 IdentityFile /var/lib/syncoid/.ssh/eve-syncoid I can connect and login to jumphost with sudo -u syncoid ssh jumphost. However, a connection to the server eve with sudo -u syncoid ssh -vvv eve results in OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021 debug1: Reading configuration data /var/lib/syncoid/.ssh/config debug1: /var/lib/syncoid/.ssh/config line 1: Applying options for eve debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 5: Applying options for * debug2: resolve_canonicalize: hostname 192.168.10.1 is address debug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W '[%h]:%p' jumphost debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/var/lib/syncoid/.ssh/known_hosts' debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/var/lib/syncoid/.ssh/known_hosts2' debug1: Executing proxy command: exec ssh -vvv -W '[192.168.10.1]:22' jumphost debug1: identity file /var/lib/syncoid/.ssh/eve-syncoid type 0 debug1: identity file /var/lib/syncoid/.ssh/eve-syncoid-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.8 debug1: kex_exchange_identification: banner line 0: This account is currently not available. kex_exchange_identification: Connection closed by remote host Connection closed by UNKNOWN port 65535 Do I need a regular user with a shell to perform a ProxyJump? Edit: A login to eve without ProxyJump over VPN works, so everything is correct with the keys and the config. I created a normal user with the same keys/config and there the ProxyJump works.
This is actually not a ProxyJump problem - the service is a hardened systemd service with a limited RootDirectory, so it cannot access the private ssh key. The folder with the private key has to be added to the BindReadonlyPaths following this github comment config.services.syncoid.service.serviceConfig.BindReadOnlyPaths = [ "/var/lib/syncoid/.ssh" ]; Following the comment further this will be solved by this pull request in the future.
SSH: ProxyJump from user without shell
1,625,864,176,000
If I set a custom path for AuthorizedKeysFile, how does sshd decide which user this key belongs to? AuthorizedKeysFile Specifies the file that contains the public keys that can be used for user authentication. AuthorizedKeysFile may contain tokens of the form %T which are substituted during connection setup. The following tokens are defined: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user. After expansion, AuthorizedKeysFile is taken to be an absolute path or one relative to the user's home directory. The default is ''.ssh/authorized_keys''.
sshd doesn’t need to decide which user a key belongs to; it knows which user is attempting to connect (user on the target system), and it knows which key is provided in the attempt. After expansion, the file pointed to by AuthorizedKeysFile is used to determine whether the provided key is allowed for the target user. Again, it already knows which user this is (and it needs to to replace %u or find the file in the first place when it’s relative to the target user’s home directory).
How does sshd know which user belongs to which AuthorizedKeysFile?
1,625,864,176,000
I have two machines devbox, and gitbox. The second machine, gitbox is a development box that has no shell, and is very locked down just to afford git over ssh (there isn't access to /bin/true even) What I want to do is add to devbox's .ssh/known_hosts the entry for gitbox. Currently what I do is, ssh -oStrictHostKeyChecking=no git.server.com __NOOP__ This does what I want, but it has to attempt to run __NOOP__, ideally I would like to just add to the known_hosts file. Is there a method of doing this?
Try ssh-keyscan , then append the output to ~/.ssh/known_hosts ssh-keyscan git.server.com >> ~/.ssh/known_hosts
Simply adding to SSH known_host without forcing an error?
1,625,864,176,000
I'am running a script to connect to another host (via ssh) and it's doing some deployment work. I need to detect the ssh connection is closed/or interrupted, then need to execute a command to delete session_directories in the remote host. I was trying pam_session_close, but it can remove directories with the ssh session_close or disconnect. But I need to do both work (shell script connection to remote host and deploy package then delete the temp directories once session is closed or terminated. what is the best method to do that? How can I use a shell script to do this? The shell script will connect and deploy the work, and also monitor the session. If the shell script detects the session, it should remove temp directories per that particular session. (I can get the temp directory name from my script in that session.) Appreciate your thoughts on this.
You could run a script that uses trap on SIGHUP.
Probe SSH connection and detect ssh disconnect or logout
1,625,864,176,000
I've just set up OpenSSH on my system (Ubuntu 18.04 LTS), and generated the key using ssh-keygen. When prompted for password, I set it to just one character to test, but when I try to copy the public key onto the server, it keeps saying: ssh-copy-id user@ip /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys user@ip's password: Permission denied, please try again. user@ip's password: Permission denied, please try again. user@ip's password: user@ip's: Permission denied (publickey,password). The ip above was obtained from ipchicken. Port forwarding on 22 is turned on in my router, but another device is also configured to that. I have a static IP with different devices configured to it. Is it possible that this is interfering with my connection? If not, how do I resolve this issue?
You just generated a new key. You can not use that key to connect to a remote host since the public key is not available on it yet. To copy the key, you will have to use your user's password on that host (unless it has another of your public SSH keys already, which I in this case doubt), not the password for the key.
SSH password permission denied
1,625,864,176,000
I have fresh installed Manjaro version 17. Then I install OpenSSH, My aim is to start SSH on boot. SO I did below sudo pacman -Sy openssh sudo systemctl start sshd.service sudo systemctl enable sshd.service I enable Firewall too, at every boot I have to login to system than only I can connect to SSH. I also enable sudo systemctl start sshd.socket sudo systemctl enable sshd.socket But still same. I am using Wifi and I feel that until I login my wifi is not connecting and it is not getting IP due to that SSH is not work. Kindly somebody help me.
You should use netctl. It is the Arch Linux built in network management system. If it isn't already installed (it should be though), run pacman -Syu netctl then look in /etc/netctl. There are example configuration files in /etc/netctl/examples. To use an example, just copy it to /etc/netctl and edit it to fit your set up. So for your case, run cp /etc/netctl/example/wireless-wpa /etc/netctl/somedescriptivename then edit /etc/netctl/somedescriptivename to fit your set up. To enable auto configuration of your wireless networks with systemd, make sure the wpa_actiond package is installed and enable the service: systemctl enable [email protected] For more information please refer to the Netctl wiki entry. From : https://unix.stackexchange.com/a/83108/237568
Manjaro Connect SSH & Wifi before log in
1,625,864,176,000
When I connect to my computer over ssh on the local network, putty fives me the correct fingerprint of ssh-rsa 2048 ad:e3:4c:e3:d0:6f:81:2e:05:94:77:6c:0f:2c:a8:7f This matches the fingerprint on my computer when I run ssh-keygen -E md5 -lf /etc/ssh/ssh_host_rsa_key.pub When I connect over the internet putty gives me a fingerprint of ssh-rsa 1040 86:03:d0:87:3d:67:3a:9a:9b:83:7a:39:a7:2e:e7:e0 Why is it giving me a different fingerprint, what is this ssh-rsa 1040?
If you cannot confirm that key fingerprint as coming from your ubuntu host, the likely cause is that you are not really connecting to the host/service that you think you are. Not only are you getting a different host key, the key length of 1040 seems a bit peculiar. Doing a quick google search on the fingerprint 86:03:d0:87:3d:67:3a:9a:9b:83:7a:39:a7:2e:e7:e0 finds a hit in a gist of "Top 1,000 Duplicate SSH Fingerprints on the Internet", while not conclusive, at least makes it even more suspect. Plausibly, it may be that your router has a SSH service, and your connection is your router instead of the server behind it. Since your ubuntu host is local, you can check the logs on the server to see if the ssh connection is being made (and check that the source IP is what you expect). Also check the client side netstat listing of established connections to validate that the destination IP matches what you expect. If you cannot find a legitimate reason for that key fingerprint to be originating from your server, assume that it is not your server. If you attempted to login with a password, successfully or unsuccessfully, to a server with that fingerprint, assume that your username/password has been compromised by some unknown party.
Why are there 2 different fingerprints for ssh depending on what network I connect from?
1,625,864,176,000
I have Linux mint on my pc. I have a public/private key pair to ssh into my router without having to type the password. It works on Windows using putty, but Mint isn't when I run it from terminal. ssh -i privkey.ppk [email protected]
You need to convert keys generated by putty to a form that can be used by openssh. There are several good answers explaining various ways of doing this at https://stackoverflow.com/questions/2224066/how-to-convert-ssh-keypairs-generated-using-puttygenwindows-into-key-pairs-use
Why am I still being asked for an ssh password when I'm using private key authentication?
1,625,864,176,000
Question is simple: What are the (private) key types and (their specification - format, syntax) accepted by current openSSH? The vague answer "the keys generated by ssh-keygen" is not accepted - I know it. They are called PEM with such headers (RSA, DSA, ECDSA variations): -----BEGIN RSA PRIVATE KEY----- The other format is described in PROTOCOL.key and is extension by openssh. It is also used as a default for Ed25519 keys, as stated in manual and (regardless passphrase) marked with header: -----BEGIN OPENSSH PRIVATE KEY----- There are also legacy RSA1 keys that should be gone today with SSHv1 protocol, but can be identified by the header: SSH PRIVATE KEY FILE FORMAT 1.1 Are there any others? I am searching for more verbose description of other keys. I didn't find it (so far) explicitly specified in any manual page nor in any RFC for SSH. The bonus question (not needed to answer, but I would appreciate the insight): What is the reason behind (openssh) decoding every dummy file and asking for a passphrase, even if it does not have the proper header? Footnote: Question was originally posted on openssh-unix-dev list, but so far without any answer so I am trying this awesome community, if there is somebody able to answer it.
TL;DR The most helpful comments from @forcefsck. Unfortunately he didn't fill the answer so I was unable to award the bounty. In short, the answer is PEM + RSA1 + new openSSH format which is described in the question and the main problem was with PEM. The long one & Bonus OpenSSH is using parser from openSSL (PEM_read_bio_PrivateKey()), which has the only return value for all the failures (NULL) and if it fails, openSSH expects it was because of wrong passphrase. Without OpenSSL I just tried to build OpenSSH without OpenSSL support (--without-openssl configure option) and the behaviour is "correct": # ./ssh-add <(echo "") Error loading key "/dev/fd/63": invalid format Fix with OpenSSL The other thing is how to fix it. The poke comes from ERR_get_error() function and their friends which should allow us to distinguish between different errors. Wrong passphrase errors # ./ssh-add /tmp/rsa 140480353842840:error:0906A068:lib(9):func(106):reason(104):pem_lib.c:457: Enter passphrase for /tmp/rsa: 140480353842840:error:06065064:lib(6):func(101):reason(100):evp_enc.c:592: 140480353842840:error:0906A065:lib(9):func(106):reason(101):pem_lib.c:482: Reasons: PEM_R_BAD_PASSWORD_READ, PEM_R_BAD_BASE64_DECODE, PEM_R_BAD_DECRYPT. Parse error codes # ./ssh-add <(echo "") 139656018548376:error:0906D06C:lib(9):func(109):reason(108):pem_lib.c:701:Expecting: ANY PRIVATE KEY or this: 140654301202072:error:0906D066:lib(9):func(109):reason(102):pem_lib.c:809: Reason: PEM_R_NO_START_LINE, PEM_R_BAD_END_LINE, but there might be more possibilities. Solution? Adding some more checks for OpenSSL errors should give us an option to choose which error we want to mark as "format" error and which is "bad passphrase". This is located in function sshkey_parse_private_pem_fileblob() in sshkey.c on line around 3800. unsigned long e = ERR_get_error(); if (ERR_GET_REASON(e) == PEM_R_NO_START_LINE || ERR_GET_REASON(e) == PEM_R_BAD_END_LINE) { r = SSH_ERR_INVALID_FORMAT; } else { r = SSH_ERR_KEY_WRONG_PASSPHRASE; }
What are the keys accepted by openSSH?
1,625,864,176,000
Anyone know how to make ssh source the users enviroment? ssh -Y -t old-dash '"bundle exec rails server" bash: bundle exec rails server: command not found Connection to old-dash closed. one@localhost ~/github/ui $ I have the below in my .bashrc and I do not think it is getting sourced: export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"
See if this helps you. ssh <host> bash --login -c <command> Start bash as a login shell through SSH and then load the rbenv via SSH's -c option.
SSH run command in users rbenv enviroment
1,625,864,176,000
So I've installed OpenSSH on Mint rafaela 17.2, but it doesn't seem to be running when using the modified config file. Not sure why service says its up, but I don't have a PID, don't have a listener, and can't connect at all... service --status-all shows [-] ssh. service ssh start returns start: Job is already running:ssh ssh localhost returns connection refused ps ax | grep ssh returns only the ssh-agent. ss -lnp | grep ssh shows the gnome-keyring and ssh-agent listening, but not the ssh daemon. (grep sshd returns nothing at all) I followed this for the setup - https://help.ubuntu.com/community/SSH/OpenSSH/Configuring Any thoughts? I've been searching for hours on how to start the damn service and getting nothing. Edit (More Info) Played around some more, switched back to the default sshd config file and running service ssh restart returns ssh stop/waiting and ssh start/running, process When I put the modified config file back in place and did a restart, no process ID comes up. Looked at the log file, when trying to restart sshd with the new config file I see the following- Aug 29 17:58:25 serenity kernel: [ 3867.828744] init: ssh main process (6151) terminated with status 255 Aug 29 17:58:25 serenity kernel: [ 3867.828754] init: ssh main process ended, respawning Aug 29 17:58:31 serenity kernel: [ 3873.631306] [UFW AUDIT] IN= OUT=eth0 SRC=10.0.0.8 DST=255.255.255.255 LEN=142 TOS=0x00 PREC=0x00 TTL=64 ID=65238 DF PROTO=UDP SPT=17500 DPT=17500 LEN=122 Aug 29 17:58:31 serenity kernel: [ 3873.631323] [UFW ALLOW] IN= OUT=eth0 SRC=10.0.0.8 DST=255.255.255.255 LEN=142 TOS=0x00 PREC=0x00 TTL=64 ID=65238 DF PROTO=UDP SPT=17500 DPT=17500 LEN=122 Aug 29 17:58:31 serenity kernel: [ 3873.631346] [UFW AUDIT] IN=eth0 OUT= MAC= SRC=10.0.0.8 DST=255.255.255.255 LEN=142 TOS=0x00 PREC=0x00 TTL=64 ID=65238 DF PROTO=UDP SPT=17500 DPT=17500 LEN=122 Aug 29 17:58:39 serenity kernel: [ 3881.610999] [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:1d:d1:7a:3c:91:08:00 SRC=10.0.0.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0x00 TTL=1 ID=0 DF PROTO=2 Default and new config files changes listed diff sshd_config (NEW CONFIG) sshd_config.bckp (DEFAULT CONFIG) 24c24 < LogLevel VERBOSE --- > LogLevel INFO 27c27 < LoginGraceTime 30 --- > LoginGraceTime 120 52c52 < PasswordAuthentication no --- > #PasswordAuthentication yes 71,72c71,72 < MaxStartups 2:30:10 < Banner /etc/issue.net --- > #MaxStartups 10:30:60 > #Banner /etc/issue.net 89,94d88 < < AllowTcpForwarding no < < AllowUsers <username> < < ForwardAgent no
Sort of figured it out. Obviously something in the config file was stopping the server from starting. After implementing each file change one line at a time, finally found it was the ForwardAgent no line in the config that was causing problems. After some more digging, found that you could start the daemon direct instead of through the services to see if you were getting an error message. /usr/sbin/sshd -Ddp 10222 /etc/ssh/sshd_config: line 90: Bad configuration option: ForwardAgent /etc/ssh/sshd_config: terminating, 1 bad configuration options I don't know why the ForwardAgent setting there is causing issues, but commenting that out let me finally run the server.
Installed OpenSSH on Mint 17 but it doesn't seem to be running
1,625,864,176,000
I have a chrooted SFTP user group to access my home server. The chroot location is /mnt/, mostly because it is already owned by root and is where I have mounted the external HDD I want to the chrooted user group to access. Moreover, I got 'Permission Denied' errors when I had the chroot directory at /home/[user] (even after assuring that it was owned by root) I've generated RSA keys in order to disable passwords authentication entirely, but I can't copy them to the home server because my chrooted user does not have write permissions to /mnt! Is there any workaround?
Copy them in as root and then chown them to the required owner.
SFTP Chroot and SSH
1,625,864,176,000
I am running Ubuntu 22.04.3 with an sFTP server configured through SSHD. I have several user home directories each with a dropoff and a pickup folder inside of them. While my admin user is able to navigate the server and view the contents of any directory. The admin is unable to add or remove any files from the other users directories. The aforementioned pickup and dropoff directories are owned by root and the group is marked as 'sftp'. This sftp group contains all of the users that I wish to have accessing my server and picking up/dropping off files. My admin user is not part of the sftp group. When I add the admin to the SFTP group, I am no longer able to access the server as the admin. When the admin is not part of the group, I am able to access the server but am unable to add/remove files from directories belonging to the sftp group. My sshd.conf is as follows: AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server PasswordAuthentication yes Match group sftp ChrootDirectory /home/%u X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp Any guidance will be much appreciated. Edit 1: ls -ld pickup shows drwxrwxr-x 2 root sftp 4096 Dec 18 16:22 pickup Edit 2: I am using WinSCP and FileZilla to connect to the server. I have a user that is not familiar with terminal usage and needs to send files to and from clients. This admin account can currently view all files on the server but cannot add or remove any files (such as .xlsx). I am not going to give someone with no terminal experience or understanding of what SFTP is total access and control over the server. That would be unintelligent. What I am trying to do is create an account for myself for testing. So that I know what permissions and properties to grant this account before giving it to my user. As it stands the account can view files in a directory such as /home/client1/dropoff but cannot add or remove files from the dropoff directory. I need the account to be able to navigate through /home/ and into all of the client directories, and sub-directories, and add or remove files at will. Currently my client users can only access their home directory /client1/ and the corresponding sub-directories. They can add or remove files with no problem as the clients accounts are members of a 'sftp' group and so are the sub-directories. I have tried adding this admin account to the sftp group, but when I do that I am no longer able to connect to the server via WinSCP or FileZilla. I have tried changing the Protocol options for the SFTP Environment settings from 'Default' to 'sudo su -c /bin/sftp-server' within WinSCP but this gives me the error Cannot initialize SFTP protocol. Is the host running an SFTP server? which I know it is because when I examine the server and protocol information the File transfer protocol is labeled 'SFTP-3'. The groups my admin account belongs to are as follows: sudo adm cdrom dip plugdev lxd ftpadmin
Based on the comments, what you call "admin user" should rather be called something like a "FTP/SFTP janitor user". You should create a group for this purpose, and make both the "admin user" and the users that have pickup/dropoff directories members of that group. The sftp group is not suitable for this purpose, because the Match clause in the sshd_config file restricts members of that group to their home directories and SFTP-only access. Obviously you don't want that to happen to the "admin user", because they would then not be able to do the job of managing the pickup/dropoff directories. The pickup/dropoff directories should be owned by the respective user, and chgrp'ed to this new group. Then you should set a chmod g+swx to the pickup/dropoff directory: this will cause any new files dropped in by the pickup/dropoff user to assume the group ownership of the new group, and will allow members of the new group that can access the directory (i.e. the pickup/dropoff user themselves, and the admin user) read/write access. The admin user should be a member of the new group, but not of the sftp group. After the permissions are set in this manner, you could remove the powerful sudo and adm group memberships from any non-command-line-savvy admin accounts. If you want to restrict the admin user to SFTP access only (because you said they are unfamiliar with command line), then you might write a new Match block to sshd_config for admin users, located after the Match group sftp block: Match group <new group> X11Forwarding no AllowTCPForwarding no ForceCommand internal-sftp This prevents using the admin user account for command-line access, making it strictly a SFTP-based administration account for pickup/dropoff directories. Since this setup is based on group memberships, you can later add new pickup/dropoff admin accounts by simply creating a user and adding them to this new group.
sFTP admin permission denied when placing files into user directory
1,625,864,176,000
By now, we are using OpenSSH GSSAPI authentication on all of our servers (Debian from 10 to 12). Then we sudo -i, using ldap authentication (through sssd-ldap). I would like to get rid of the ldap authentication and rely on GSSAPI only, both for OpenSSH and Sudo. The idea is to to forward Ticket service to Openssh (host/fqdn), keep it in the credentials cache (typically /tmp/krb5...) and keep that TGS to also authenticate sudo (I found that pam_sss_gss.so could authenticate sudo with GSSAPI). The problem is...OpenSSH destroys the Ticket service once it's validated. Here are my questions: Is there a way to keep the ticket service forwarded to openssh inside a credential cache? It would help me to authenticate sudo afterward. If 1 is not possible (and i guess it is indeed not), are there any security concerns about forwarding TGT on all of our servers? (TGT lifetime is 4 hours). I would have to open a flow between servers and KDC port 88 on our firewall. I'd rather avoid NOPASSWD inside sudoers, but if members of group sudo authenticate via kerberos, are there any security concerns about putting NOPASSWD inside sudoers for that group? Let me know whether you have other ideas, i would really appreciate it. Thank you.
Is there a way to keep the ticket service forwarded to openssh inside a credential cache? It would help me to authenticate sudo afterward. No, there's no option to do that. (It would be possible in theory, but it's not an implemented function.) However, it might be possible to use PAM to acquire a "S4U2self" ticket, where the service uses its own keytab to get a ticket to itself "on behalf of" the user. (See e.g. kvno -I.) (Also it's called a service ticket, not ticket service.) If 1 is not possible (and i guess it is indeed not), are there any security concerns about forwarding TGT on all of our servers? (TGT lifetime is 4 hours). There are, very similar to SSH agent forwarding. Even though the long-term credentials cannot be stolen, the 4-hour TGT in theory could be stolen (and extended all the way up to their renewable lifetime – not just up to their normal lifetime). It's up to you to decide whether that's a significant concern in your case, i.e. how hardened the servers are against someone getting root access and reading other users' tickets. I would have to open a flow between servers and KDC port 88 on our firewall. That shouldn't be an issue. (In fact, I don't understand why that isn't already open.) I'd rather avoid NOPASSWD inside sudoers, but if members of group sudo authenticate via kerberos, are there any security concerns about putting NOPASSWD inside sudoers for that group? What you're planning already functions like NOPASSWD – the idea is that if pam_sss_gssapi succeeds, it will immediately return out of PAM without reaching the "ask for password" pam_unix module at all. However, if you enabled NOPASSWD, it would bypass the Kerberos authentication as well. The reason is that Sudo doesn't prompt for password explicitly – it only calls PAM to authenticate the user, and the NOPASSWD flag actually means "no PAM authentication". (It does not mean "no password" as such; it just happens that the standard PAM module (pam_unix) asks for a password.) But if you enable NOPASSWD, then sudo will never call PAM for auth, therefore skipping both pam_unix and pam_sss_gss. Windows Kerberos uses PAC to forward groups membership. Do you have any idea why is that feature not implemented in MIT Kerberos? MIT Kerberos, being the "original" Kerberos distribution, continues to follow its original design where authorization (access control) is explicitly not part of Kerberos functionality – it is purely an authentication system. I mean NSS from Linux has to poll the LDAP frequently to feed its databases about the users and groups. It doesn't poll LDAP at any frequency; it queries LDAP only when a user is "logged in" – not significantly different from Windows.
How to authenticate through OpenSSH then sudo with only one Ticket Service (Kerberos TGS host/fqdn)
1,625,864,176,000
I made my Arcolinux (5.12.14-arch1-1 x86_64) unusable by trying to install openssh. Googled a few hours and tried something, but without success. I did the following: $sudo pacman -S openvpn Then vpn sayed that it requires oppenssl, so I installed it $sudo pacman -S openssl Then I tried to start openvpn and got an error "missing libcrypto.so.1.1" Unfortunately many applications (including sudo and pacman!) seem to depend on this library so I can not start them anymore. After some googling I downloaded libcrypto from here https://archlinux.org/packages/core/x86_64/openssl-1.1/ And copied the libcrypto.so.1.1 file to /usr/lib/ (using sh, because sudo wont work) Then I tried to start pacman und sudo again and got another error: sudo: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /usr/lib/libcrypto.so.1.1) Now, probably I could try to coppy this file as well and so on, but I think this is not the right way to solve the problem cleanly. How can I revert to the state before instaling openssl (above) What did I wrong while installing openssh? I thought / relied on that pacman considers the dependencies and does not remove a lib automatically if there is another app or lib that depends on it? Many thanks for hints or guidance!
Based on your kernel version (5.12.14-arch1-1 x86_64) you apparently haven't updated your Arch installation in about 15 months. Keeping up with a rolling-release distribution like Arch tends to require frequent updating. The distribution maintainers cannot guarantee that you will be able to install the newest packages to any old installation: the web of dependencies that needs to be managed becomes exponentially more complex as the time range between your currently installed packages and the up-to-date state of the distribution grows. Unless all the packages have their dependency information absolutely perfect all the time, as the time between updates grows, so does also the risk of encountering a dependency that is not automatically detectable. And for you, that risk seems to have been realized. You should have installed all updates to your installed packages at least once a month, maybe even once a week. Instead, you installed the absolutely latest packages of openvpn and openssl into your one-and-half-years old system. Unfortunately, it looks like the new openssl is built against a newer version of glibc than your system currently has. In order to solve this problem, you might have needed a version of openssl that is somewhere in between your system's original version and the current up-to-date version... but it is possible that the version you would need has already expired from Arch's repositories, since your system is in such an old state. If so, then "there is no way to get there from here": the rolling release has rolled away from you and you can't catch it any more. The easiest way forward would be to restore from a backup, and then attempt a full upgrade to the up-to-date state before trying to install any software that is not already present. But even that might not be successful, since your system seems to be in such an old state. It might be possible to recover from your current situation with a "manual intervention" (as the Arch Wiki calls it), however it is likely that reinstalling from scratch and restoring your data from backup might be easier and faster. If you don't have a backup? Then I would suggest booting from some external media, mounting the filesystems of this installation, backing up all your data and configuration files, and then reinstalling.
Missing libraries after installing openssl (libcrypto.so.1.1, ...)
1,625,864,176,000
I used that form to create my ssh key : ssh-keygen -t ed25519 -C "[email protected]" and I got: Encryption: aes256-cbc, is it possible to use [email protected] instead? thanks
man 1 ssh-keygen states : -Z cipher Specifies the cipher to use for encryption when writing an OpenSSH-format private key file. The list of available ciphers may be obtained using "ssh -Q cipher". The default is “aes256-ctr”. ssh-keygen -t ed25519 -Z "[email protected]" -C "[email protected]" Should work just fine
How to generate ssh key with AES-GCM?
1,625,864,176,000
I read this question Get SSH server key fingerprint In the answer and solution appears the following command (adapted here for presentation purposes) ssh-keyscan 192.168.1.X | ssh-keygen -lf - I know that the first command isolated shows the public keys of the host. When the complete command is executed - thus the two parts - according with the final output, the public keys of the first command are used to generate the fingerprint of themselves. question How does - work in the ssh-keygen -lf - command? It is mandatory. I know l is to show the fingerprint and f to define a filename, but how is interpreted -?
By default, ssh-keygen -l will ask you interactively for what public key file to show the fingerprint of. With -f you give it the pathname of some existing file instead. If the pathname is - (a dash), input is read from standard input instead of from a file. This is a common practice that quite a few other commands also follow, most notably cat (cat - reads from standard input). In your pipeline, the data on standard input is provided by the ssh-keyscan command. The ssh-keyscan command will extract the public key of the mentioned host and pass it on to ssh-keygen -l. The ssh-keygen utility will output the fingerprint. Without -f -, the ssh-keygen utility would try to use the output of ssh-keyscan as the filename to read the key from. This is arguably bad design, as it's easy to programmatically determine whether the input to a program comes from a terminal or something that is not a terminal (like another command or a file). So in a sense, -f - could be made unnecessary.
How does "-" work in the "ssh-keygen -lf -" command?
1,625,864,176,000
I read this question: How do I extract fingerprints from .ssh/known_hosts? The answer is valid, so I tried some variations: ssh-keygen -lf ~/.ssh/known_hosts -F 192.168.1.X ssh-keygen -lvf ~/.ssh/known_hosts -F 192.168.1.X ssh-keygen -E md5 -lvf ~/.ssh/known_hosts -F 192.168.1.X ssh-keygen -E sha256 -lvf ~/.ssh/known_hosts -F 192.168.1.X All work as expected. How an observation: for any command share above, it shows all the fingerprint together based in their own key types, such as rsa, ecdsa etc .... I am ok with this, but ... the reason of this post Question: How to execute the ssh-keygen command with a filter for a specific key type? Something similar as the ssh-keyscan has with the -t option, therefore something like: ssh-keygen -lf ~/.ssh/known_hosts -F 192.168.1.X -? rsa ssh-keygen -lf ~/.ssh/known_hosts -F 192.168.1.X -? ecdsa So what could be ?? - I saw the ssh-keygen --help and seems there is no that support.
In Korn-like shells, you could always do: ssh-keygen -lf <(grep ' ssh-rsa ' ~/.ssh/known_hosts) -F localhost Same with fish: ssh-keygen -lf (grep ' ssh-rsa ' ~/.ssh/known_hosts|psub) -F localhost Or other shells assuming a system that has /dev/stdin (most these days): grep ' ssh-rsa ' ~/.ssh/known_hosts | ssh-keygen -lf /dev/stdin -F localhost That assumes ssh-rsa is not found anywhere else on the lines of those known_hosts files (like in comments or options).
How do I extract fingerprints from .ssh/known_hosts? but filtering for a specific key type
1,625,864,176,000
In Ubuntu and Fedora in the /etc/ssh/ directory exists the following files: ssh_host_key ssh_host_dsa_key (not available in Fedora) ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key For the same set of these files, exists others with the same names but with the .pub extension. I know that dsa, ecdsa, ed25519 and rsa are keys type Questions What is the key type for the ssh_host_key file in SSH?
ssh_host_key is the key for the deprecated OpenSSH protocol version 1. It is always RSA. -h host_key_file Specifies a file from which a host key is read. […] The default is /etc/ssh/ssh_host_key for protocol version 1, […] — man 8 sshd
What is the key type for the ssh_host_key file in SSH?
1,625,864,176,000
I have the following problem: I have a remote machine accessible via ssh which can serve some data through a web interface. I can use OpenSSH LocalForwarding to open a tunnel and start the remote server: ssh [email protected] -L 127.0.0.1:3333:localhost:4000 ./start.sh then, on another terminal (or from GUI), I can start a browser, e.g.: firefox localhost:3333/whatever and access content served by my app. After use I simply give [CTRL-C] to start.sh to close server, connection and tunnel. So far so good. Question is: Is it possible to write a script combining everything in such a way the tunnel is closed when browser terminates? To be more precise I would like a script that: Opens the tunnel and starts remote server (as above). Automatically opens a browser (firefox is ok, but not a must) on the right port (which could be randomly generated). Keeps tunnel up while browser is running. When browser terminates (I am aware there could be other open windows, but that's beyond the point) it should send a signal (SIGHUP) to server (start.sh). When remote server terminates tunnel should be closed (this should be automatic with the above setup) I would like to keep tunnel and server up-and-running for the time strictly needed, avoiding to "forget closing" as it can happen if I have to do it manually. How can I do this?
It turns out answer is a bit more convoluted than expected. I ended up writing a full init script for the server: #!/bin/sh # use start-stop-daemon to control zero-ui set -e # Must be a valid filename NAME=zero-ui PIDFILE=/home/user/$NAME.pid DAEMON=/usr/bin/node DAEMON_OPTS="/home/user/zero-ui/backend/bin/www" export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" export NODE_ENV=production export ZU_SECURE_HEADERS=false export ZU_SERVE_FRONTEND=true export ZU_CONTROLLER_TOKEN=... export ZU_DISABLE_AUTH=true export ZU_DEFAULT_USERNAME=... export ZU_DEFAULT_PASSWORD=... case "$1" in start) echo -n "Starting daemon: "$NAME start-stop-daemon --start --quiet --pidfile $PIDFILE -m --exec $DAEMON --chdir /home/user/zero-ui/backend -- $DAEMON_OPTS echo "." ;; stop) echo -n "Stopping daemon: "$NAME start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE echo "." ;; *) echo "Usage: "$1" {start|stop}" exit 1 esac exit 0 Then I call it with the following script: #!/bin/sh set -e ssh -n -L 127.0.0.1:3333:localhost:4000 user@server ./start-stop-zeroui start & firefox localhost:3333/app ssh user@server ./start-stop-zeroui stop fg If @larsks or anyone else comes up with a better answer I'll gladly accept their answer, otherwise I'll accept my own in a few days. I upvoted @larsks because it sparked the idea.
opening a temporary tunnel