ssh: Could not resolve hostname sama5d27-som1-ek-sd: - linux

I am trying to set up remote connection between my Desktop machine ( Windows machine ) and remote machine ( Linux machine ).
For that, I am following the steps described here :
https://learn.microsoft.com/en-us/cpp/linux/set-up-fips-compliant-secure-remote-linux-development?view=vs-2019#to-create-and-use-an-rsa-key-file
But, in step 2, when I try, From Windows, to copy the public key to the Linux machine using this command :
scp C:\Users\wiemz/.ssh/id_rsa.pub root#sama5d27-som1-ek-sd:
This error occurs :
ssh: Could not resolve hostname sama5d27-som1-ek-sd: H\364te Unknown.
lost connection
I verfied my Linux internet connection with ping command and it's going well. Besides, when I typed this command on the Linux machine :
ssh root#sama5d27-som1-ek-sd
it says :
ssh: Could not resolve hostname sama5d27-som1-ek-sd: Temporary failure
in name resolution
How can I fix this problem please ?

The problem is your OS can't resolve the hostname you use. You should provide FQDN like web.example.com or IP address of the machine. For example
scp file root#IP:
or
scp file root#web.example.com:

Related

How to open a xterm terminal in a SSH connection with a remote Ubuntu without GUI

I am using Mininet on a remote Ubuntu without GUI. And I am trying to use "xterm h1" to open a terminal on a virtual host in Mininet. But it showed me always there is no display connected. I am trying to use other X application like firefox and it showed me
"No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0.0"
Then I have set X11forward yes in sshd_config on the remote Ubuntu, and install Xlaunch on my windows but showed no changes.
Can someone tell me how to solve this problem?
PS. I am using a pycharm on Windows11 to establish this SSH session
Since you are running windows you will first need an application that will run an X11 server on your windows, Xming, for example. You will then need to configure your ssh connection to use that xserver. Finally you want to setup the DISPLAY variable at your remote to be LOCAL_IP:0 where LOCAL_IP is the public IP of your machine.

Scp connection timed out ubuntu VM

so i'm trying to copy a file for my directory to Azure ubuntu VM , SSH works just fine ,but scp command takes a lot of time and then i had this message
connect to host 10.x.x.x port 22: Connection timed out lost connection
this is the command i used :
scp -vvv -i .ssh/id_rsa BaltimoreCyberTrustRoot.crt.pem azureuser#10.x.x.x:/var/www/html
• AFAIK, the SCP command that you are using to try to connect to your Ubuntu Azure VM might not be correct as the correct command to connect to your Ubuntu Linux VM from your local machine to copy files between them is as follows: -
scp -r ./tmp/ azureuser#10.xxx.xxx.xxx:/home/file/user/local
In the above command, the SCP connection gets established successfully after entering the private key further which files in the local system in ‘/tmp’ directory is recursively getting copied in the Azure ubuntu VM specified in ‘/home/file/user/local’ directory. Thus, the whole directory tree as specified is copied from the local system to the Azure ubuntu VM.
• Also, if you want to use the private key in the ‘SCP’ command through SSH, then you will have to use the below command to copy files from the local system to the Azure ubuntu VM: -
sudo scp -i ~/.ssh/id_rsa /path/cert.pem azureuser#10.xxx.xxx.xxx:/home/file/user/local
Using ‘sudo’ to access a ‘root’ file, while ‘SCP’ is going to look for the identity file ‘id_rsa’ in ‘/root/.ssh/’ instead of in ‘/home/user/.ssh/’. That's why you will have to specify the identity file (private key) in the SCP command to connect to the Azure ubuntu VM and transfer files from local system to the VM.
Other than this, kindly ensure that port 22 is opened in the inbound NSG rule on the Azure ubuntu VM and the VM's default page is accessible on port 80/443 over public IP address and the Azure FQDN assigned.
For more information, kindly refer to the links below: -
Can't scp to Azure's VM
https://learn.microsoft.com/en-us/azure/virtual-machines/linux/copy-files-to-linux-vm-using-scp#scp-a-directory-from-a-linux-vm

Unable to transfer local file wsl ubuntu terminal to remote server using windows subsystem

I have a file called test1.zip in /mnt/c/Users/test/ folder of my local laptop [in which ubuntu windows subsystem for linux is installed]. Local ubuntu terminal WSL name is lauda
Now, I would like to transfer this zip file called test1.zip to my remote server named stuff.
PLEASE NOTE THAT ALL COMMANDS ARE TRIED FROM MY LOCAL LAPTOP WSL SCREEN [ubuntu screen]
So, I tried the below command from my WSL [local laptop ubuntu WSL terminal]
scp user1#lauda:/mnt/c/Users/test/test1.zip user1#stuff:/home/test/codes/test1
and got the error ssh: Could not resolve hostname lauda: Name or service not known
So I tried the below [replacing the lauda local laptop ubuntu terminal hostname with its IP]
scp user1#172.xx.xxx.xxx:/mnt/c/Users/test/test1.zip user1#stuff:/home/test/codes/test1
this resulted in error as ssh: connect to host 172.xx.xxx.xxx port 22: Connection refused
Now I tried the same command as above but in opposite way as shown below
scp user1#stuff:/home/test/codes/ user1#lauda:/mnt/c/Users/test/test1.zip
and got the below error
ssh: Could not resolve hostname lauda: Temporary failure in name resolution
Later, I tried with IP address
scp user1#stuff:/home/test/codes/ user1#172.xx.xxx.xxx:/mnt/c/Users/test/test1.zip
And I got the below error
ssh: connect to host 172.xx.xxx.xxx port 22: No route to host lost connection
Later, I tried the below commands as well
scp /mnt/c/Users/test/test1.zip user1#stuff:/home/test/codes/
and got an error scp: /home/test/codes/test1.zip: Permission denied
So, I again tried like below
scp user1#stuff:/home/test/codes/ /mnt/c/Users/test/test1.zip
and got an error scp: /home/test/codes: not a regular file
PLEASE NOTE THAT ALL COMMANDS ARE TRIED FROM MY LOCAL LAPTOP WSL SCREEN [ubuntu screen]
How can I transfer local files/folders from my local ubuntu WSL terminal to remote server?
scp /mnt/c/Users/test/test1.zip user1#stuff:/home/test/codes/ is the closest attempt to working. The error you get could be due to one of two reasons:
Firstly user1 does not have permissions to write to /home/test on stuff - makes sense as usually only the test user would be able to write there. (Note that the test user on your WSL instance is not the same profile the test user on the remote.)
Secondly the /home/test/codes/ folder may not even exist yet.
Instead (if you know test's password) copy as the test user :
scp /mnt/c/Users/test/test1.zip test#stuff:/home/test/codes/
Or copy to user1's home directory (after ensuring you have created /home/user1/codes/
scp /mnt/c/Users/test/test1.zip user1#stuff:/home/user1/codes/

Issues with using Jump Host

How do I transfer a file from my local machine to a remote host to which I need to get through a jump host? These are the steps I follow to connect to the remote host
1. ssh myname#jump-host
2. enter password
3. sudo su - another-random-name
4. ssh name#remote-host
Now I want to transfer a file from my local machine to the remote-host. How would I achieve this? I have already tried scp -oProxyCommand but I don't quite know where I should include step 3 as part of this command?
Use port forwarding to get third host ssh port on your localhost, in this way:
ssh -L 2222:remote-host:22 myname#jump-host
then (on another tab/shell on first host):
scp -P 2222 file myname#localhost:
will copy directly to remote host.
On the jump host under another-random-name run
ssh -L 2222:remote-host:22 myname#jump-host
then on your local computer you can run
scp -P 2222 file name#jump-host:
SCP will try to connect to jump-host, while in fact this connection will be forwarded to jump-host. And will use name as it is connecting to remote-host.
You are probably still facing problem with certificate for another-random-user. You can either create certificate on your machine for your-local-user and put public key on remote-host in user allowed keys.

SCP command not working - need to copy file from Windows localhost to Linux

I need to copy file admin.zip from C:\wamp\www\jdhemumbai060714\webfiles (Windows) to /var/www/html/ (Linux). I am using following command::
scp C:\wamp\www\jdhemumbai060714\webfiles\admin.zip username#hostname:/var/www/html/
But it does not work and gives error::
ssh: Could not resolve hostname C: Temporary failure in name resolution
I am logged in Linux server using SSH
I think that it is bug in SCP port.
Only way is skip "C:" and use only "\wamp\www\jdhemumbai060714\webfiles\admin.zip"
It will work if current directory is on the same disk like file for upload.
Or you can use pscp.exe
Well firstly is your DNS server able to resolve the HOSTNAME your copying too? My Advice would be to use IP Address.
scp C:\wamp\www\jdhemumbai060714\webfiles\admin.zip username#192.168.0.2:/var/www/html/
BELOW ANSWER APPLICABLE ONLY FOR EC2 OR WHICH HAS PEM KEY.
Open Windows CMD, and Type
scp -i Keypair_Along_with_Path.pem YOUR_FILENAME_ALONG_WITH_PATH.txt USERNAME#PUBLIC-IP:DESTINATION_PATH
Real Example:
scp -i C:\Users\Keypair.pem C:\Users\File.txt ubuntu#1.1.1.1:/tmp/.
You are done.

Resources