<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.csclub.uwaterloo.ca/index.php?action=history&amp;feed=atom&amp;title=How_to_SSH</id>
	<title>How to SSH - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.csclub.uwaterloo.ca/index.php?action=history&amp;feed=atom&amp;title=How_to_SSH"/>
	<link rel="alternate" type="text/html" href="https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;action=history"/>
	<updated>2026-04-05T21:09:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;diff=4859&amp;oldid=prev</id>
		<title>Merenber: /* Public key-based authentication */</title>
		<link rel="alternate" type="text/html" href="https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;diff=4859&amp;oldid=prev"/>
		<updated>2022-08-24T02:25:29Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Public key-based authentication&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:25, 23 August 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;nano ~/.ssh/authorized_keys&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;nano ~/.ssh/authorized_keys&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Paste your public key into this file. Once you are done, save and close the file (if you are using nano, run Ctrl-O, Ctrl-X).&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Paste your public key into this file. Once you are done, save and close the file (if you are using nano, run Ctrl-O&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, Enter&lt;/ins&gt;, Ctrl-X).&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now whenever you run the SSH command from your computer, you won&#039;t need to enter a password anymore.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now whenever you run the SSH command from your computer, you won&#039;t need to enter a password anymore.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Merenber</name></author>
	</entry>
	<entry>
		<id>https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;diff=4857&amp;oldid=prev</id>
		<title>Merenber: /* SOCKS proxy */</title>
		<link rel="alternate" type="text/html" href="https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;diff=4857&amp;oldid=prev"/>
		<updated>2022-08-24T02:22:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;SOCKS proxy&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:22, 23 August 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== SOCKS proxy ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== SOCKS proxy ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is useful for when you want to proxy all of the traffic for a particular application through a remote. This requires SOCKS &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;proxy&lt;/del&gt; from the application. Firefox is one such application, which is useful if you want to visit a website which can only be accessed from an on-campus IP address. Run the following first (you can choose a different port if you want):&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is useful for when you want to proxy all of the traffic for a particular application through a remote. This requires SOCKS &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;support&lt;/ins&gt; from the application. Firefox is one such application, which is useful if you want to visit a website which can only be accessed from an on-campus IP address. Run the following first (you can choose a different port if you want):&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ssh -D 8132 ctdalek@corn-syrup.csclub.uwaterloo.ca&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;ssh -D 8132 ctdalek@corn-syrup.csclub.uwaterloo.ca&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Merenber</name></author>
	</entry>
	<entry>
		<id>https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;diff=4856&amp;oldid=prev</id>
		<title>Merenber: Created page with &quot;[https://linux.die.net/man/1/ssh SSH], or &lt;b&gt;S&lt;/b&gt;ecure &lt;b&gt;SH&lt;/b&gt;ell, is a program used to securely login to a remote computer. As of this writing, the &lt;code&gt;ssh&lt;/code&gt; comman...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.csclub.uwaterloo.ca/index.php?title=How_to_SSH&amp;diff=4856&amp;oldid=prev"/>
		<updated>2022-08-24T02:19:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;[https://linux.die.net/man/1/ssh SSH], or &amp;lt;b&amp;gt;S&amp;lt;/b&amp;gt;ecure &amp;lt;b&amp;gt;SH&amp;lt;/b&amp;gt;ell, is a program used to securely login to a remote computer. As of this writing, the &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; comman...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[https://linux.die.net/man/1/ssh SSH], or &amp;lt;b&amp;gt;S&amp;lt;/b&amp;gt;ecure &amp;lt;b&amp;gt;SH&amp;lt;/b&amp;gt;ell, is a program used to securely login to a remote computer. As of this writing, the &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; command is builtin to Windows, MacOS, and Linux, so you do not need to install any third-party software to use it. However, if you are using Windows, I suggest using a dedicated terminal emulator such as Windows Terminal or Git Bash instead of the old batch command prompt window, which does not handle all ANSI escape sequences properly.&lt;br /&gt;
&lt;br /&gt;
== Password-based authentication ==&lt;br /&gt;
See [[Machine List]] for a list of general-use machines which you may SSH into. Let&amp;#039;s say your CSC username is &amp;lt;code&amp;gt;ctdalek&amp;lt;/code&amp;gt; and you want to use the &amp;lt;code&amp;gt;corn-syrup&amp;lt;/code&amp;gt; machine. Then run the following command from your terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh ctdalek@corn-syrup.csclub.uwaterloo.ca&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then enter your password. If this is your first time, check the email you received from CSC when you signed up; it should contain a temporary password in it.&lt;br /&gt;
&lt;br /&gt;
If you are off-campus, you will also be prompted for a 2FA code via DUO (see [[Two-Factor Authentication]] for details). Since this is annoying, I suggest setting up public key-based authentication instead (see below).&lt;br /&gt;
&lt;br /&gt;
== Public key-based authentication ==&lt;br /&gt;
Pubkey auth is far more convenient since you do not have to enter your password every time. If you are a CS student, chances are that you may already have created an SSH key for one of your courses; if not, just run the command &amp;lt;code&amp;gt;ssh-keygen&amp;lt;/code&amp;gt; and follow the prompts.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ssh-keygen&amp;lt;/code&amp;gt; command will create two files: a private key and a public key, by default named id_rsa and id_rsa.pub. (If you chose ED25519 as your signature algorithm, these will be named id_ed25519 and id_ed25519.pub instead). You will want to get the content of the public key file.&lt;br /&gt;
&lt;br /&gt;
On MacOS, Linux, Git Bash and PowerShell, run the following command to print the file&amp;#039;s content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat ~/.ssh/id_rsa.pub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using the old Windows command prompt, run the following instead:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
type %USERPROFILE%\.ssh\id_rsa.pub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the output to your clipboard. It will look something like this (example only):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCzaWV...hNUzpnsbVsHGZy7k= ctdalek@desktop-pc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note that the last part (in this case, &amp;quot;ctdalek@desktop-pc&amp;quot;) is just a comment - you can actually put anything you want there.&lt;br /&gt;
&lt;br /&gt;
Now SSH into a CSC machine. If you do not have a &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory yet in your home directory, create it now:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir ~/.ssh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now open the file &amp;lt;code&amp;gt;~/.ssh/authorized_keys&amp;lt;/code&amp;gt;. In this example we will use the nano text editor, but any editor will do.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nano ~/.ssh/authorized_keys&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Paste your public key into this file. Once you are done, save and close the file (if you are using nano, run Ctrl-O, Ctrl-X).&lt;br /&gt;
&lt;br /&gt;
Now whenever you run the SSH command from your computer, you won&amp;#039;t need to enter a password anymore.&lt;br /&gt;
&lt;br /&gt;
== ssh_config ==&lt;br /&gt;
SSH has a lot of different configuration options which can be placed in the file &amp;lt;code&amp;gt;~/.ssh/config&amp;lt;/code&amp;gt; (on your local computer, not the remote). See https://linux.die.net/man/5/ssh_config for a reference. Here&amp;#039;s a basic config file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Host csc&lt;br /&gt;
    HostName corn-syrup.csclub.uwaterloo.ca&lt;br /&gt;
    User ctdalek&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now whenever you run &amp;lt;code&amp;gt;ssh csc&amp;lt;/code&amp;gt; from your terminal, you will login to corn-syrup.&lt;br /&gt;
&lt;br /&gt;
== Forward proxy ==&lt;br /&gt;
Let&amp;#039;s say you&amp;#039;re running a server program on a CSC machine, and it&amp;#039;s running on localhost:3000 on the remote. One way to access this locally is to use a forward proxy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh -L 3000:localhost:3000 ctdalek@corn-syrup.csclub.uwaterloo.ca&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now localhost:3000 on your local machine will be forwarded to localhost:3000 on the remote.&lt;br /&gt;
&lt;br /&gt;
== Reverse proxy ==&lt;br /&gt;
Let&amp;#039;s say you&amp;#039;re running a server program locally listening on localhost:3000, and you want to access this from the remote. In this case, you want to create a reverse proxy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh -R 3000:localhost:3000 ctdalek@corn-syrup.csclub.uwaterloo.ca&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now localhost:3000 on the remote will be forwarded to localhost:3000 on your computer.&lt;br /&gt;
&lt;br /&gt;
== SOCKS proxy ==&lt;br /&gt;
This is useful for when you want to proxy all of the traffic for a particular application through a remote. This requires SOCKS proxy from the application. Firefox is one such application, which is useful if you want to visit a website which can only be accessed from an on-campus IP address. Run the following first (you can choose a different port if you want):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh -D 8132 ctdalek@corn-syrup.csclub.uwaterloo.ca&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now in Firefox, go to the URL &amp;lt;code&amp;gt;about:preferences&amp;lt;/code&amp;gt;, scroll to the bottom, click on the Settings button, choose &amp;quot;Manual proxy configuration&amp;quot;, set SOCKS Host to localhost, and set the port to 8132. Also choose &amp;quot;SOCKS v5&amp;quot; and check the &amp;quot;Proxy DNS when using SOCKS v5&amp;quot; option. Now click OK. All of Firefox&amp;#039;s network connections should now be proxied through the remote machine.&lt;/div&gt;</summary>
		<author><name>Merenber</name></author>
	</entry>
</feed>