Can malware travel back to my computer over an SSH session?

Not by itself: an ordinary SSH session carries your keystrokes and the server's screen output, and a compromised server cannot push a program onto your computer through it. The risks come from the features you add. Agent forwarding lets the server use your SSH keys while you are connected, so a compromised server can reach other servers as you; use it only towards trusted hosts, or use a jump-host setting instead. Port forwarding and X11 forwarding open channels back to your machine. Files you copy from the server can carry malware like any download. And a vulnerable SSH client can in principle be attacked by a malicious server, so keep the client updated. On the network, a session from an admin laptop to a server is normal; NetSenX flags unusual sessions between hosts as lateral movement, on every plan, so an SSH session that starts hopping onwards from a server stands out.

Read next

← All 40 questions on Remote work and exposed servicesAll topics